From 38022ca586e41d5031bc91e37b309fa895d61226 Mon Sep 17 00:00:00 2001 From: iambibi_ <89582596+iambibi@users.noreply.github.com> Date: Tue, 7 Apr 2026 18:20:12 +0200 Subject: [PATCH 1/2] Rewrite feature loading + reorganize utils packages --- .../openmc/api/chronometer/Chronometer.java | 6 +- .../api/cooldown/CooldownInterceptor.java | 2 +- .../api/cooldown/DynamicCooldownManager.java | 15 +- .../input}/dialog/ButtonType.java | 2 +- .../api/input/{ => dialog}/DialogInput.java | 3 +- .../api/input/location/ItemInteraction.java | 10 +- src/main/java/fr/openmc/api/menulib/Menu.java | 8 +- .../java/fr/openmc/api/menulib/MenuLib.java | 2 +- .../api/menulib/template/ConfirmMenu.java | 6 +- .../openmc/api/menulib/utils/ItemBuilder.java | 6 +- src/main/java/fr/openmc/core/OMCPlugin.java | 203 ++++++++---------- .../core/bootstrap/features/Feature.java | 48 +++++ .../features/types/DatabaseFeature.java | 13 ++ .../features/types/LoadAfterItemsAdder.java | 7 + .../integration/DatabaseManager.java | 93 ++++++++ .../integration}/ErrorReporter.java | 6 +- .../commands/admin/freeze/FreezeListener.java | 6 +- .../commands/admin/freeze/FreezeManager.java | 19 +- .../fr/openmc/core/commands/fun/Diceroll.java | 6 +- .../fr/openmc/core/commands/fun/Playtime.java | 10 +- .../openmc/core/commands/utils/Cooldowns.java | 8 +- .../core/commands/utils/RTPCommands.java | 8 +- .../openmc/core/commands/utils/Restart.java | 7 +- .../openmc/core/commands/utils/SetSpawn.java | 7 +- .../fr/openmc/core/commands/utils/Spawn.java | 10 +- .../core/commands/utils/SpawnManager.java | 11 +- .../corporation/commands/ShopCommand.java.bak | 2 +- .../corporation/company/Company.java.bak | 2 +- .../manager/CompanyManager.java.bak | 2 +- .../menu/company/CompanyBaltopMenu.java.bak | 2 +- .../menu/company/CompanyMenu.java.bak | 2 +- .../corporation/menu/shop/ShopMenu.java.bak | 2 +- .../menu/shop/ShopSearchMenu.java.bak | 6 +- .../menu/shop/ShopStocksMenu.java.bak | 2 +- .../disabled/corporation/shops/Shop.java.bak | 2 +- .../corporation/shops/ShopItem.java.bak | 2 +- .../openmc/core/events/ArmorEquipEvent.java | 38 +++- .../features/adminshop/AdminShopManager.java | 19 +- .../features/adminshop/AdminShopYAML.java | 2 +- .../adminshop/menus/ColorVariantsMenu.java | 2 +- .../features/adminshop/menus/ConfirmMenu.java | 4 +- .../adminshop/menus/LeavesVariantsMenu.java | 2 +- .../adminshop/menus/LogVariantsMenu.java | 2 +- .../features/analytics/AnalyticsManager.java | 17 +- .../animations/AnimationsManager.java | 12 +- .../core/features/city/ChunkDataCache.java | 4 +- .../fr/openmc/core/features/city/City.java | 10 +- .../core/features/city/CityChatManager.java | 6 +- .../core/features/city/CityManager.java | 38 +++- .../features/city/ProtectionsManager.java | 6 +- .../city/actions/CityChangeAction.java | 8 +- .../city/actions/CityChestAction.java | 8 +- .../city/actions/CityClaimAction.java | 10 +- .../city/actions/CityCreateAction.java | 8 +- .../city/actions/CityDeleteAction.java | 6 +- .../features/city/actions/CityKickAction.java | 6 +- .../city/actions/CityLeaveAction.java | 6 +- .../city/actions/CityTransferAction.java | 6 +- .../city/actions/CityUnclaimAction.java | 8 +- .../city/commands/AdminCityCommands.java | 6 +- .../features/city/commands/CityCommands.java | 12 +- .../city/commands/CityInviteCommands.java | 6 +- .../city/commands/CityPermsCommands.java | 6 +- .../city/commands/CityTopCommands.java | 6 +- .../city/conditions/CityChestConditions.java | 8 +- .../city/conditions/CityClaimCondition.java | 8 +- .../city/conditions/CityCreateConditions.java | 10 +- .../city/conditions/CityInviteConditions.java | 6 +- .../city/conditions/CityKickCondition.java | 6 +- .../city/conditions/CityLeaveCondition.java | 6 +- .../city/conditions/CityManageConditions.java | 6 +- .../city/conditions/CityPermsConditions.java | 6 +- .../city/conditions/CityTypeConditions.java | 8 +- .../city/conditions/CityUnclaimCondition.java | 6 +- .../protections/ExplodeProtection.java | 6 +- .../features/city/menu/CityChunkMenu.java | 10 +- .../features/city/menu/CityModifyMenu.java | 14 +- .../features/city/menu/CityPermsMenu.java | 6 +- .../core/features/city/menu/CityTopMenu.java | 2 +- .../features/city/menu/CityTransferMenu.java | 8 +- .../core/features/city/menu/NoCityMenu.java | 12 +- .../city/menu/list/CityListDetailsMenu.java | 2 +- .../features/city/menu/list/CityListMenu.java | 2 +- .../city/menu/list/CityPlayerListMenu.java | 2 +- .../city/menu/main/buttons/BankButton.java | 6 +- .../city/menu/main/buttons/ManageButton.java | 6 +- .../city/menu/main/buttons/MapButton.java | 6 +- .../city/menu/main/buttons/MascotsButton.java | 2 +- .../city/menu/main/buttons/MayorButton.java | 2 +- .../menu/main/buttons/MilestoneButton.java | 6 +- .../menu/main/buttons/NotationsButton.java | 2 +- .../city/menu/main/buttons/RankButton.java | 6 +- .../city/menu/main/buttons/TypeButton.java | 2 +- .../playerlist/CityPlayerGestionMenu.java | 4 +- .../menu/playerlist/CityPlayerListMenu.java | 14 +- .../features/city/models/DBCityChest.java | 2 +- .../features/city/models/DBCityClaim.java | 2 +- .../core/features/city/models/DBCityRank.java | 6 +- .../city/sub/bank/CityBankManager.java | 8 +- .../bank/conditions/CityBankConditions.java | 6 +- .../sub/bank/menu/CityBankDepositMenu.java | 6 +- .../city/sub/bank/menu/CityBankMenu.java | 8 +- .../sub/bank/menu/CityBankWithdrawMenu.java | 6 +- .../city/sub/mascots/MascotsManager.java | 23 +- .../commands/AdminMascotsCommands.java | 6 +- .../listeners/MascotsDamageListener.java | 6 +- .../listeners/MascotsInteractionListener.java | 6 +- .../listeners/MascotsRenameListener.java | 6 +- .../city/sub/mascots/menu/MascotMenu.java | 10 +- .../sub/mascots/menu/MascotsDeadMenu.java | 10 +- .../sub/mascots/menu/MascotsSkinMenu.java | 8 +- .../city/sub/mascots/models/MascotType.java | 2 +- .../sub/mayor/actions/MayorCommandAction.java | 6 +- .../sub/mayor/actions/MayorSetWarpAction.java | 6 +- .../mayor/commands/AdminMayorCommands.java | 6 +- .../sub/mayor/commands/MayorCommands.java | 8 +- .../sub/mayor/listeners/PhaseListener.java | 2 +- .../sub/mayor/listeners/UrneListener.java | 8 +- .../city/sub/mayor/managers/NPCManager.java | 6 +- .../sub/mayor/menu/MayorElectionMenu.java | 11 +- .../city/sub/mayor/menu/MayorLawMenu.java | 8 +- .../city/sub/mayor/menu/MayorMandateMenu.java | 3 +- .../city/sub/mayor/menu/MayorVoteMenu.java | 10 +- .../sub/mayor/menu/create/MayorColorMenu.java | 8 +- .../mayor/menu/create/MayorCreateMenu.java | 6 +- .../mayor/menu/create/MayorModifyMenu.java | 2 +- .../sub/mayor/menu/create/PerkChoiceMenu.java | 6 +- .../city/sub/mayor/menu/npc/MayorNpcMenu.java | 9 +- .../city/sub/mayor/menu/npc/OwnerNpcMenu.java | 9 +- .../features/city/sub/mayor/models/Mayor.java | 2 +- .../city/sub/mayor/models/MayorCandidate.java | 2 +- .../sub/mayor/perks/basic/AyweniterPerk.java | 6 +- .../sub/mayor/perks/basic/GPSTrackerPerk.java | 6 +- .../sub/mayor/perks/basic/IronBloodPerk.java | 8 +- .../perks/event/AgriculturalEssorPerk.java | 10 +- .../sub/mayor/perks/event/IdyllicRain.java | 2 +- .../mayor/perks/event/ImpotCollection.java | 6 +- .../mayor/perks/event/MilitaryDissuasion.java | 2 +- .../mayor/perks/event/MineralRushPerk.java | 10 +- .../commands/AdminCityMilestoneCommands.java | 6 +- .../listeners/CooldownEndListener.java | 6 +- .../sub/milestone/menu/CityMilestoneMenu.java | 2 +- .../requirements/ItemDepositRequirement.java | 8 +- .../city/sub/notation/NotationManager.java | 2 +- .../commands/AdminNotationCommands.java | 10 +- .../notation/commands/NotationCommands.java | 8 +- .../listeners/PlayerJoinListener.java | 8 +- .../sub/notation/menu/NotationDialog.java | 6 +- .../notation/menu/NotationEditionDialog.java | 8 +- .../city/sub/rank/CityRankAction.java | 8 +- .../city/sub/rank/CityRankCommands.java | 6 +- .../city/sub/rank/CityRankCondition.java | 6 +- .../sub/rank/menus/CityRankAssignMenu.java | 6 +- .../sub/rank/menus/CityRankDetailsMenu.java | 8 +- .../city/sub/rank/menus/CityRankIconMenu.java | 6 +- .../sub/rank/menus/CityRankMemberMenu.java | 8 +- .../sub/rank/menus/CityRankPermsMenu.java | 6 +- .../core/features/city/sub/war/War.java | 2 +- .../features/city/sub/war/WarManager.java | 2 +- .../city/sub/war/actions/WarActions.java | 6 +- .../sub/war/commands/AdminWarCommand.java | 6 +- .../city/sub/war/commands/WarCommand.java | 8 +- .../sub/war/listeners/TntPlaceListener.java | 6 +- .../city/sub/war/menu/main/MainWarMenu.java | 2 +- .../sub/war/menu/main/WarPlayerListMenu.java | 2 +- .../selection/WarChooseParticipantsMenu.java | 8 +- .../core/features/city/view/CityViewData.java | 2 +- .../features/city/view/CityViewManager.java | 10 +- .../core/features/cube/CubeCommands.java | 6 +- .../cube/multiblocks/MultiBlockManager.java | 16 +- .../core/features/displays/TabList.java | 12 +- .../displays/bossbar/BossbarManager.java | 17 +- .../bossbar/commands/BossBarCommand.java | 6 +- .../displays/holograms/HologramInfo.java | 2 +- .../displays/holograms/HologramLoader.java | 30 ++- .../holograms/commands/HologramCommand.java | 6 +- .../displays/scoreboards/BaseScoreboard.java | 2 +- .../scoreboards/ScoreboardManager.java | 12 +- .../scoreboards/sb/CityWarScoreboard.java | 6 +- .../scoreboards/sb/MainScoreboard.java | 4 +- .../scoreboards/sb/RestartScoreboard.java | 4 +- .../core/features/dream/DreamManager.java | 31 +-- .../core/features/dream/DreamUtils.java | 8 +- .../dream/commands/DreamCommands.java | 6 +- .../dream/commands/DreamItemCommand.java | 6 +- .../dream/displays/DreamScoreboard.java | 4 +- .../features/dream/generation/DreamBiome.java | 2 +- .../generation/DreamDimensionManager.java | 4 +- .../populators/glacite/CavePopulator.java | 2 +- .../glacite/GlaciteGeodePopulator.java | 4 +- .../populators/mud/RockPopulator.java | 4 +- .../plains/PlainsTreePopulator.java | 4 +- .../soulforest/PillarPopulator.java | 4 +- .../soulforest/SoulTreePopulator.java | 4 +- .../structures/DreamStructurePopulator.java | 2 +- .../cloud/CloudCastleStructure.java | 2 +- .../structures/glacite/BaseCampStructure.java | 2 +- .../soulforest/SoulAltarStructure.java | 2 +- .../listeners/biomes/PlayerEnteredBiome.java | 8 +- .../dream/listeners/orb/PlayerObtainOrb.java | 6 +- .../registry/DreamItemDropsListener.java | 6 +- .../dream/mecanism/altar/AltarListener.java | 6 +- .../dream/mecanism/altar/AltarManager.java | 8 +- .../cloudfishing/CloudFishingManager.java | 4 +- .../cloudfishing/PlayerFishListener.java | 6 +- .../dream/mecanism/cold/ColdManager.java | 4 +- .../metaldetector/MetalDetectorListener.java | 8 +- .../metaldetector/MetalDetectorTask.java | 2 +- .../singularity/SingularityContents.java | 2 +- .../mecanism/tradernpc/GlaciteTradeMenu.java | 8 +- .../features/dream/models/db/DreamPlayer.java | 8 +- .../registries/enchantements/Soulbound.java | 8 +- .../registries/items/tools/MetalDetector.java | 6 +- .../registries/items/tools/MeteoWand.java | 8 +- .../dream/registries/mobs/Breezy.java | 2 +- .../features/dream/registries/mobs/Soul.java | 2 +- .../core/features/economy/BankManager.java | 23 +- .../core/features/economy/EconomyManager.java | 26 ++- .../features/economy/TransactionsManager.java | 17 +- .../economy/commands/BankCommands.java | 6 +- .../core/features/economy/commands/Money.java | 6 +- .../core/features/economy/commands/Pay.java | 6 +- .../economy/menu/PersonalBankDepositMenu.java | 4 +- .../economy/menu/PersonalBankMenu.java | 8 +- .../menu/PersonalBankWithdrawMenu.java | 4 +- .../halloween/managers/HalloweenManager.java | 14 +- .../menus/HalloweenPumpkinDepositMenu.java | 8 +- .../weeklyevents/WeeklyEventsManager.java | 18 +- .../contest/commands/ContestCommand.java | 8 +- .../contest/managers/ContestManager.java | 29 ++- .../contest/menu/ContributionMenu.java | 12 +- .../contents/contest/menu/TradeMenu.java | 8 +- .../contents/contest/menu/VoteMenu.java | 8 +- .../core/features/friend/FriendCommand.java | 6 +- .../core/features/friend/FriendRequest.java | 6 +- .../features/friend/FriendSQLManager.java | 17 +- .../features/homes/HomeUpgradeManager.java | 8 +- .../core/features/homes/HomesManager.java | 28 +-- .../homes/command/DelHomeCommand.java | 6 +- .../homes/command/HomeWorldCommand.java | 6 +- .../homes/command/RelocateHomeCommand.java | 6 +- .../homes/command/RenameHomeCommand.java | 6 +- .../homes/command/SetHomeCommand.java | 6 +- .../features/homes/command/TpHomeCommand.java | 8 +- .../features/homes/icons/CachedIconItem.java | 6 +- .../homes/icons/HomeIconCacheManager.java | 14 +- .../homes/menu/HomeChangeIconMenu.java | 12 +- .../features/homes/menu/HomeConfigMenu.java | 10 +- .../homes/menu/HomeDeleteConfirmMenu.java | 6 +- .../core/features/homes/menu/HomeMenu.java | 6 +- .../leaderboards/LeaderboardManager.java | 33 ++- .../commands/LeaderboardCommands.java | 6 +- .../core/features/mailboxes/Letter.java | 2 +- .../features/mailboxes/MailboxCommand.java | 7 +- .../features/mailboxes/MailboxManager.java | 27 ++- .../features/mailboxes/letter/LetterHead.java | 5 +- .../mailboxes/letter/SenderLetter.java | 4 +- .../mailboxes/menu/PendingMailbox.java | 10 +- .../features/mailboxes/menu/PlayersList.java | 2 +- .../mailboxes/menu/letter/LetterMenu.java | 11 +- .../mailboxes/menu/letter/SendingLetter.java | 14 +- .../mailboxes/utils/MailboxMenuManager.java | 6 +- .../core/features/mainmenu/MainMenu.java | 15 +- .../core/features/mainmenu/menus/Page1.java | 8 +- .../core/features/mainmenu/menus/Page2.java | 6 +- .../milestones/MilestonesManager.java | 16 +- .../milestones/tutorial/TutorialHologram.java | 4 +- .../tutorial/quests/BreakAyweniteQuest.java | 4 +- .../tutorial/quests/CityCreateQuest.java | 4 +- .../tutorial/quests/CityLevelTwoQuest.java | 4 +- .../tutorial/quests/ClaimLetterQuest.java | 4 +- .../tutorial/quests/FinishQuestQuest.java | 4 +- .../tutorial/quests/HomeCreateQuest.java | 4 +- .../tutorial/quests/HomeUpgradeQuest.java | 4 +- .../quests/OpenAdminShopMenuQuest.java | 4 +- .../tutorial/quests/OpenContestMenuQuest.java | 4 +- .../tutorial/quests/OpenQuestMenuQuest.java | 4 +- .../quests/OpenSettingsMenuQuest.java | 4 +- .../tutorial/quests/SellBuyQuest.java | 4 +- .../tutorial/quests/SpareBankQuest.java | 4 +- .../privatemessage/PrivateMessageManager.java | 6 +- .../privatemessage/SocialSpyManager.java | 6 +- .../command/SocialSpyCommand.java | 6 +- .../core/features/quests/QuestsManager.java | 14 +- .../features/quests/command/QuestCommand.java | 6 +- .../core/features/quests/objects/Quest.java | 8 +- .../features/quests/quests/BreakLogQuest.java | 2 +- .../quests/quests/CraftTheMixtureQuest.java | 2 +- .../quests/rewards/QuestMoneyReward.java | 6 +- .../quests/rewards/QuestTextReward.java | 6 +- .../settings/PlayerSettingsManager.java | 17 +- .../settings/menu/PlayerSettingsMenu.java | 6 +- .../core/features/tickets/TicketManager.java | 19 +- .../tickets/menus/MachineBallsMenu.java | 6 +- .../tickets/menus/MachineBallsOpenMenu.java | 6 +- .../fr/openmc/core/features/tpa/TPAQueue.java | 17 +- .../tpa/commands/TPACancelCommand.java | 6 +- .../features/tpa/commands/TPACommand.java | 6 +- .../features/tpa/commands/TPADenyCommand.java | 6 +- .../tpa/commands/TPAcceptCommand.java | 8 +- .../core/features/updates/UpdateManager.java | 11 +- .../openmc/core/listeners/ArmorListener.java | 19 +- .../listeners/JoinQuitMessageListener.java | 6 +- .../core/listeners/PlayerDeathListener.java | 6 +- .../core/registry/items/CustomItem.java | 2 +- .../java/fr/openmc/core/utils/ArmorType.java | 41 ---- ...dWebhook.java => DiscordWebhookUtils.java} | 2 +- .../fr/openmc/core/utils/ShutUpOrmLite.java | 34 --- .../core/utils/{ => bukkit}/ItemUtils.java | 8 +- .../utils/{ => bukkit}/MaterialUtils.java | 2 +- .../utils/{ => bukkit}/ParticleUtils.java | 4 +- .../core/utils/{ => bukkit}/PlayerUtils.java | 2 +- .../core/utils/{ => bukkit}/SkullUtils.java | 2 +- .../serializer/BukkitSerializer.java | 2 +- .../serializer/LocationSerializer.java | 2 +- .../core/utils/database/DatabaseManager.java | 86 -------- .../core/utils/init/DatabaseFeature.java | 13 ++ .../fr/openmc/core/utils/init/Feature.java | 40 ++++ .../core/utils/init/LoadAfterItemsAdder.java | 7 + .../core/utils/init/NotUnitTestFeature.java | 7 + .../core/utils/{ => text}/ColorUtils.java | 2 +- .../core/utils/{ => text}/DateUtils.java | 2 +- .../core/utils/{ => text}/DirectionUtils.java | 2 +- .../core/utils/{ => text}/InputUtils.java | 2 +- .../core/utils/{ => text}/MotdUtils.java | 13 +- .../core/utils/{ => text}/PaddingUtils.java | 2 +- .../TranslationManager.java | 17 +- .../fonts}/CustomFonts.java | 2 +- .../{customfonts => text/fonts}/Fonts.java | 2 +- .../{ => text}/messages/MessageType.java | 2 +- .../{ => text}/messages/MessagesManager.java | 2 +- .../utils/{ => text}/messages/Prefix.java | 2 +- .../core/utils/{ => world}/EntityUtils.java | 2 +- .../core/utils/{ => world}/LocationUtils.java | 2 +- .../utils/{ => world/chunk}/ChunkInfo.java | 2 +- .../utils/{ => world/chunk}/ChunkPos.java | 2 +- .../{ => world}/entities/TextDisplay.java | 2 +- .../structure/FeaturesPopulator.java | 2 +- .../structure/SchematicsUtils.java | 2 +- .../{ => world}/structure/StructureUtils.java | 4 +- .../fr/openmc/core/utils/ColorUtilsTest.java | 1 + .../fr/openmc/core/utils/DateUtilsTest.java | 1 + .../fr/openmc/core/utils/InputUtilsTest.java | 1 + .../fr/openmc/core/utils/ItemsUtilTest.java | 1 + .../openmc/core/utils/PaddingUtilsTest.java | 1 + 345 files changed, 1657 insertions(+), 1238 deletions(-) rename src/main/java/fr/openmc/{core/utils => api/input}/dialog/ButtonType.java (89%) rename src/main/java/fr/openmc/api/input/{ => dialog}/DialogInput.java (98%) create mode 100644 src/main/java/fr/openmc/core/bootstrap/features/Feature.java create mode 100644 src/main/java/fr/openmc/core/bootstrap/features/types/DatabaseFeature.java create mode 100644 src/main/java/fr/openmc/core/bootstrap/features/types/LoadAfterItemsAdder.java create mode 100644 src/main/java/fr/openmc/core/bootstrap/integration/DatabaseManager.java rename src/main/java/fr/openmc/core/{utils/errors => bootstrap/integration}/ErrorReporter.java (97%) delete mode 100644 src/main/java/fr/openmc/core/utils/ArmorType.java rename src/main/java/fr/openmc/core/utils/{DiscordWebhook.java => DiscordWebhookUtils.java} (97%) delete mode 100644 src/main/java/fr/openmc/core/utils/ShutUpOrmLite.java rename src/main/java/fr/openmc/core/utils/{ => bukkit}/ItemUtils.java (98%) rename src/main/java/fr/openmc/core/utils/{ => bukkit}/MaterialUtils.java (98%) rename src/main/java/fr/openmc/core/utils/{ => bukkit}/ParticleUtils.java (98%) rename src/main/java/fr/openmc/core/utils/{ => bukkit}/PlayerUtils.java (98%) rename src/main/java/fr/openmc/core/utils/{ => bukkit}/SkullUtils.java (98%) rename src/main/java/fr/openmc/core/utils/{ => bukkit}/serializer/BukkitSerializer.java (97%) rename src/main/java/fr/openmc/core/utils/{ => bukkit}/serializer/LocationSerializer.java (98%) delete mode 100644 src/main/java/fr/openmc/core/utils/database/DatabaseManager.java create mode 100644 src/main/java/fr/openmc/core/utils/init/DatabaseFeature.java create mode 100644 src/main/java/fr/openmc/core/utils/init/Feature.java create mode 100644 src/main/java/fr/openmc/core/utils/init/LoadAfterItemsAdder.java create mode 100644 src/main/java/fr/openmc/core/utils/init/NotUnitTestFeature.java rename src/main/java/fr/openmc/core/utils/{ => text}/ColorUtils.java (99%) rename src/main/java/fr/openmc/core/utils/{ => text}/DateUtils.java (99%) rename src/main/java/fr/openmc/core/utils/{ => text}/DirectionUtils.java (98%) rename src/main/java/fr/openmc/core/utils/{ => text}/InputUtils.java (98%) rename src/main/java/fr/openmc/core/utils/{ => text}/MotdUtils.java (85%) rename src/main/java/fr/openmc/core/utils/{ => text}/PaddingUtils.java (90%) rename src/main/java/fr/openmc/core/utils/{translation => text}/TranslationManager.java (93%) rename src/main/java/fr/openmc/core/utils/{customfonts => text/fonts}/CustomFonts.java (93%) rename src/main/java/fr/openmc/core/utils/{customfonts => text/fonts}/Fonts.java (83%) rename src/main/java/fr/openmc/core/utils/{ => text}/messages/MessageType.java (91%) rename src/main/java/fr/openmc/core/utils/{ => text}/messages/MessagesManager.java (99%) rename src/main/java/fr/openmc/core/utils/{ => text}/messages/Prefix.java (97%) rename src/main/java/fr/openmc/core/utils/{ => world}/EntityUtils.java (96%) rename src/main/java/fr/openmc/core/utils/{ => world}/LocationUtils.java (98%) rename src/main/java/fr/openmc/core/utils/{ => world/chunk}/ChunkInfo.java (71%) rename src/main/java/fr/openmc/core/utils/{ => world/chunk}/ChunkPos.java (96%) rename src/main/java/fr/openmc/core/utils/{ => world}/entities/TextDisplay.java (99%) rename src/main/java/fr/openmc/core/utils/{ => world}/structure/FeaturesPopulator.java (95%) rename src/main/java/fr/openmc/core/utils/{ => world}/structure/SchematicsUtils.java (99%) rename src/main/java/fr/openmc/core/utils/{ => world}/structure/StructureUtils.java (99%) diff --git a/src/main/java/fr/openmc/api/chronometer/Chronometer.java b/src/main/java/fr/openmc/api/chronometer/Chronometer.java index 608cbbd8e..682e5a58d 100644 --- a/src/main/java/fr/openmc/api/chronometer/Chronometer.java +++ b/src/main/java/fr/openmc/api/chronometer/Chronometer.java @@ -1,9 +1,9 @@ package fr.openmc.api.chronometer; import fr.openmc.core.OMCPlugin; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import lombok.Getter; import net.kyori.adventure.text.Component; import org.bukkit.Bukkit; diff --git a/src/main/java/fr/openmc/api/cooldown/CooldownInterceptor.java b/src/main/java/fr/openmc/api/cooldown/CooldownInterceptor.java index 4589ad551..ca8ec4d09 100644 --- a/src/main/java/fr/openmc/api/cooldown/CooldownInterceptor.java +++ b/src/main/java/fr/openmc/api/cooldown/CooldownInterceptor.java @@ -1,6 +1,6 @@ package fr.openmc.api.cooldown; -import fr.openmc.core.utils.DateUtils; +import fr.openmc.core.utils.text.DateUtils; import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; import revxrsal.commands.bukkit.actor.BukkitCommandActor; diff --git a/src/main/java/fr/openmc/api/cooldown/DynamicCooldownManager.java b/src/main/java/fr/openmc/api/cooldown/DynamicCooldownManager.java index 5497da7df..9fd449791 100644 --- a/src/main/java/fr/openmc/api/cooldown/DynamicCooldownManager.java +++ b/src/main/java/fr/openmc/api/cooldown/DynamicCooldownManager.java @@ -7,6 +7,8 @@ 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.DatabaseFeature; import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.scheduler.BukkitTask; @@ -20,7 +22,7 @@ /** * Main class for managing cooldowns */ -public class DynamicCooldownManager { +public class DynamicCooldownManager extends Feature implements DatabaseFeature { /** * Represents a single cooldown with duration and last use time */ @@ -82,16 +84,23 @@ public long getRemaining() { } } - public static void init() { + @Override + public void init() { loadCooldowns(); } + @Override + public void save() { + DynamicCooldownManager.saveCooldowns(); + } + // Map structure: UUID -> (Group -> Cooldown) private static final Map> cooldowns = new HashMap<>(); private static Dao cooldownDao; - public static void initDB(ConnectionSource connectionSource) throws SQLException { + @Override + public void initDB(ConnectionSource connectionSource) throws SQLException { TableUtils.createTableIfNotExists(connectionSource, Cooldown.class); cooldownDao = DaoManager.createDao(connectionSource, Cooldown.class); } diff --git a/src/main/java/fr/openmc/core/utils/dialog/ButtonType.java b/src/main/java/fr/openmc/api/input/dialog/ButtonType.java similarity index 89% rename from src/main/java/fr/openmc/core/utils/dialog/ButtonType.java rename to src/main/java/fr/openmc/api/input/dialog/ButtonType.java index 2cbd06323..9367696d1 100644 --- a/src/main/java/fr/openmc/core/utils/dialog/ButtonType.java +++ b/src/main/java/fr/openmc/api/input/dialog/ButtonType.java @@ -1,4 +1,4 @@ -package fr.openmc.core.utils.dialog; +package fr.openmc.api.input.dialog; import lombok.Getter; diff --git a/src/main/java/fr/openmc/api/input/DialogInput.java b/src/main/java/fr/openmc/api/input/dialog/DialogInput.java similarity index 98% rename from src/main/java/fr/openmc/api/input/DialogInput.java rename to src/main/java/fr/openmc/api/input/dialog/DialogInput.java index d40b7d0bf..e3a1aeff0 100644 --- a/src/main/java/fr/openmc/api/input/DialogInput.java +++ b/src/main/java/fr/openmc/api/input/dialog/DialogInput.java @@ -1,6 +1,5 @@ -package fr.openmc.api.input; +package fr.openmc.api.input.dialog; -import fr.openmc.core.utils.dialog.ButtonType; import io.papermc.paper.dialog.Dialog; import io.papermc.paper.registry.data.dialog.ActionButton; import io.papermc.paper.registry.data.dialog.DialogBase; diff --git a/src/main/java/fr/openmc/api/input/location/ItemInteraction.java b/src/main/java/fr/openmc/api/input/location/ItemInteraction.java index 64ed42da0..194ef2539 100644 --- a/src/main/java/fr/openmc/api/input/location/ItemInteraction.java +++ b/src/main/java/fr/openmc/api/input/location/ItemInteraction.java @@ -4,11 +4,11 @@ import fr.openmc.api.chronometer.ChronometerInfo; import fr.openmc.api.chronometer.ChronometerType; import fr.openmc.core.OMCPlugin; -import fr.openmc.core.utils.ItemUtils; -import fr.openmc.core.utils.MaterialUtils; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.bukkit.ItemUtils; +import fr.openmc.core.utils.bukkit.MaterialUtils; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.Location; import org.bukkit.Material; diff --git a/src/main/java/fr/openmc/api/menulib/Menu.java b/src/main/java/fr/openmc/api/menulib/Menu.java index c1598c9a4..08784038f 100644 --- a/src/main/java/fr/openmc/api/menulib/Menu.java +++ b/src/main/java/fr/openmc/api/menulib/Menu.java @@ -3,10 +3,10 @@ import fr.openmc.api.menulib.events.OpenMenuEvent; import fr.openmc.api.menulib.utils.InventorySize; import fr.openmc.api.menulib.utils.ItemBuilder; -import fr.openmc.core.utils.ItemUtils; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.bukkit.ItemUtils; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import it.unimi.dsi.fastutil.objects.Object2ObjectMap; import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; import lombok.Getter; diff --git a/src/main/java/fr/openmc/api/menulib/MenuLib.java b/src/main/java/fr/openmc/api/menulib/MenuLib.java index 503da8c01..513c34728 100644 --- a/src/main/java/fr/openmc/api/menulib/MenuLib.java +++ b/src/main/java/fr/openmc/api/menulib/MenuLib.java @@ -4,7 +4,7 @@ import fr.openmc.api.menulib.utils.ItemBuilder; import fr.openmc.core.OMCPlugin; import fr.openmc.core.features.homes.menu.HomeDeleteConfirmMenu; -import fr.openmc.core.utils.ItemUtils; +import fr.openmc.core.utils.bukkit.ItemUtils; import lombok.Getter; import org.bukkit.Bukkit; import org.bukkit.NamespacedKey; diff --git a/src/main/java/fr/openmc/api/menulib/template/ConfirmMenu.java b/src/main/java/fr/openmc/api/menulib/template/ConfirmMenu.java index ea5aaf1bf..10e770ab5 100644 --- a/src/main/java/fr/openmc/api/menulib/template/ConfirmMenu.java +++ b/src/main/java/fr/openmc/api/menulib/template/ConfirmMenu.java @@ -5,9 +5,9 @@ import fr.openmc.api.menulib.utils.InventorySize; import fr.openmc.api.menulib.utils.ItemBuilder; import fr.openmc.core.registry.items.CustomItemRegistry; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.entity.Player; import org.bukkit.event.inventory.InventoryClickEvent; diff --git a/src/main/java/fr/openmc/api/menulib/utils/ItemBuilder.java b/src/main/java/fr/openmc/api/menulib/utils/ItemBuilder.java index 0623eba83..e2a4d06f0 100644 --- a/src/main/java/fr/openmc/api/menulib/utils/ItemBuilder.java +++ b/src/main/java/fr/openmc/api/menulib/utils/ItemBuilder.java @@ -4,9 +4,9 @@ import fr.openmc.api.menulib.MenuLib; import fr.openmc.api.menulib.PaginatedMenu; import fr.openmc.core.OMCPlugin; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import io.papermc.paper.datacomponent.DataComponentType; import io.papermc.paper.datacomponent.DataComponentTypes; import io.papermc.paper.datacomponent.item.TooltipDisplay; diff --git a/src/main/java/fr/openmc/core/OMCPlugin.java b/src/main/java/fr/openmc/core/OMCPlugin.java index c731d53a4..35f5e8e25 100644 --- a/src/main/java/fr/openmc/core/OMCPlugin.java +++ b/src/main/java/fr/openmc/core/OMCPlugin.java @@ -5,16 +5,17 @@ import fr.openmc.api.hooks.*; 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.types.LoadAfterItemsAdder; +import fr.openmc.core.bootstrap.integration.DatabaseManager; +import fr.openmc.core.bootstrap.integration.ErrorReporter; 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.city.CityManager; import fr.openmc.core.features.city.sub.mascots.MascotsManager; -import fr.openmc.core.features.city.sub.mayor.managers.MayorManager; -import fr.openmc.core.features.city.sub.notation.NotationManager; -import fr.openmc.core.features.city.sub.statistics.CityStatisticsManager; -import fr.openmc.core.features.city.sub.war.WarManager; import fr.openmc.core.features.cube.multiblocks.MultiBlockManager; import fr.openmc.core.features.displays.TabList; import fr.openmc.core.features.displays.bossbar.BossbarManager; @@ -24,16 +25,17 @@ import fr.openmc.core.features.dream.generation.DreamDimensionManager; 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.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.FriendSQLManager; import fr.openmc.core.features.homes.HomesManager; import fr.openmc.core.features.homes.icons.HomeIconCacheManager; 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.quests.QuestProgressSaveManager; import fr.openmc.core.features.quests.QuestsManager; import fr.openmc.core.features.settings.PlayerSettingsManager; import fr.openmc.core.features.tickets.TicketManager; @@ -42,12 +44,9 @@ import fr.openmc.core.registry.enchantments.CustomEnchantmentRegistry; import fr.openmc.core.registry.items.CustomItemRegistry; import fr.openmc.core.registry.loottable.CustomLootTableRegistry; -import fr.openmc.core.utils.MotdUtils; -import fr.openmc.core.utils.ParticleUtils; -import fr.openmc.core.utils.ShutUpOrmLite; -import fr.openmc.core.utils.database.DatabaseManager; -import fr.openmc.core.utils.errors.ErrorReporter; -import fr.openmc.core.utils.translation.TranslationManager; +import fr.openmc.core.utils.bukkit.ParticleUtils; +import fr.openmc.core.utils.text.MotdUtils; +import fr.openmc.core.utils.text.TranslationManager; import io.papermc.paper.datapack.Datapack; import lombok.Getter; import org.bukkit.Bukkit; @@ -60,6 +59,8 @@ import org.slf4j.Logger; import java.io.File; +import java.util.ArrayList; +import java.util.List; public class OMCPlugin extends JavaPlugin { @Getter @@ -69,19 +70,47 @@ public class OMCPlugin extends JavaPlugin { public static final String VANISH_META_KEY = "omcstaff.vanished"; - public static void registerEvents(Listener... listeners) { - for (Listener listener : listeners) { - instance.getServer().getPluginManager().registerEvents(listener, instance); - } - } - - public static boolean isUnitTestVersion() { - return OMCPlugin.instance.getServer().getVersion().contains("MockBukkit"); - } + // ** Registry of OMC Features + public final List REGISTRY_FEATURE = new ArrayList<>(List.of( + new TicketManager(new File(this.getDataFolder(), "data/stats")), + new SpawnManager(), + new UpdateManager(), + new EconomyManager(), + new BankManager(), + new ScoreboardManager(), + new HomesManager(), + new TPAQueue(), + new FreezeManager(), + new TransactionsManager(), + new AnalyticsManager(), + new FriendSQLManager(), + new TabList(), + new AdminShopManager(), + new BossbarManager(), + new AnimationsManager(), + new HalloweenManager(), + new MotdUtils(), + new TranslationManager(new File(this.getDataFolder(), "translations"), "fr"), + new DynamicCooldownManager(), + new MascotsManager(), + new PlayerSettingsManager(), + new MailboxManager(), + new MilestonesManager(), + new QuestsManager(), + new CityManager(), + new ContestManager(), + new WeeklyEventsManager(), + new DreamManager(), + new MultiBlockManager(), + new LeaderboardManager(), + new MainMenu(), + new HologramLoader(), + new HomeIconCacheManager() + )); @Override public void onLoad() { - LoggerFactory.setLogBackendFactory(ShutUpOrmLite::new); + LoggerFactory.setLogBackendFactory(DatabaseManager.ShutUpOrmLite::new); } @Override @@ -108,47 +137,23 @@ public void onEnable() { Datapack pack = this.getServer().getDatapackManager().getPack(getPluginMeta().getName() + "/omc"); if (pack != null) { if (pack.isEnabled()) { - getSLF4JLogger().info("\u001B[32m✔ Lancement du datapack réussi\u001B[0m"); + logSuccessMessage("Lancement du datapack réussi"); } else { - getSLF4JLogger().warn("\u001B[31m✘ Lancement du datapack échoué\u001B[0m"); + logErrorMessage("Lancement du datapack échoué"); } } } new ErrorReporter(); /* MANAGERS */ - TicketManager.loadPlayerStats(new File(this.getDataFolder(), "data/stats")); DatabaseManager.init(); CommandsManager.init(); - SpawnManager.init(); - UpdateManager.init(); ListenersManager.init(); - EconomyManager.init(); - BankManager.init(); - - if (!isUnitTestVersion()) - ScoreboardManager.init(); - - HomesManager.init(); - TPAQueue.initCommand(); - FreezeManager.init(); - QuestProgressSaveManager.init(); - if (!isUnitTestVersion()) - TabList.init(); - AdminShopManager.init(); - BossbarManager.init(); - AnimationsManager.init(); - HalloweenManager.init(); - MotdUtils.init(); - TranslationManager.init(new File(this.getDataFolder(), "translations"), "fr"); - DynamicCooldownManager.init(); - - MascotsManager.init(); - - PlayerSettingsManager.loadAllPlayerSettings(); - - MailboxManager.loadLetters(); + /* FEATURES */ + REGISTRY_FEATURE.stream() + .filter(f -> !(f instanceof LoadAfterItemsAdder)) + .forEachOrdered(Feature::startInit); } public void loadWithItemsAdder() { @@ -158,78 +163,23 @@ public void loadWithItemsAdder() { CustomLootTableRegistry.init(); // ** FEATURES ** - MilestonesManager.init(); - QuestsManager.init(); - CityManager.init(); - ContestManager.init(); - WeeklyEventsManager.init(); - DreamManager.init(); - MultiBlockManager.init(); - if (WorldGuardHook.isHasWorldGuard()) { - ParticleUtils.spawnParticlesInRegion("spawn", Bukkit.getWorld("world"), Particle.CHERRY_LEAVES, 50, 70, 130); - ParticleUtils.spawnContestParticlesInRegion("spawn", Bukkit.getWorld("world"), 10, 70, 135); - } + REGISTRY_FEATURE.stream() + .filter(f -> f instanceof LoadAfterItemsAdder) + .forEachOrdered(Feature::startInit); + // todo: sera supprimé dans https://github.com/ServerOpenMC/PluginV2/pull/1168 DreamDimensionManager.postInit(); - if (!OMCPlugin.isUnitTestVersion()) { - LeaderboardManager.init(); - MainMenu.init(this); - HologramLoader.init(); + + if (WorldGuardHook.isHasWorldGuard()) { + ParticleUtils.spawnParticlesInRegion("spawn", Bukkit.getWorld("world"), Particle.CHERRY_LEAVES, 50, 70, 130); } - HomeIconCacheManager.initialize(); } @Override public void onDisable() { - // SAUVEGARDE - // - Dimension des Reves - DreamManager.disable(); - - // - Mailboxes - MailboxManager.saveLetters(); - - // - MultiBlocks - MultiBlockManager.save(); - - // - War - WarManager.saveWarHistories(); - - // - CityStatistics - CityStatisticsManager.saveCityStatistics(); - - // - Settings - PlayerSettingsManager.saveAllSettings(); - - // - Notation des Villes - NotationManager.saveNotations(); - - // - Maires - MayorManager.saveMayorConstant(); - MayorManager.savePlayersVote(); - MayorManager.saveMayorCandidates(); - MayorManager.saveCityMayors(); - MayorManager.saveCityLaws(); - - HomesManager.saveHomesData(); - HomeIconCacheManager.clearCache(); - - // - Milestones - MilestonesManager.saveMilestonesData(); - - // - Contest - ContestManager.saveContestData(); - ContestManager.saveContestPlayerData(); - QuestsManager.saveQuests(); - - // - Mascottes - MascotsManager.saveMascots(); - - // - Cooldowns - DynamicCooldownManager.saveCooldowns(); - - - if (!OMCPlugin.isUnitTestVersion()) { - HologramLoader.unloadAll(); + // ** SAVE ** + for (Feature feature : REGISTRY_FEATURE) { + feature.startSave(); } // - Close all inventories @@ -243,8 +193,27 @@ public void onDisable() { Bukkit.shutdown(); } + public static void registerEvents(Listener... listeners) { + for (Listener listener : listeners) { + instance.getServer().getPluginManager().registerEvents(listener, instance); + } + } + + public static boolean isUnitTestVersion() { + return OMCPlugin.instance.getServer().getVersion().contains("MockBukkit"); + } + + /* LOG MESSAGE */ + public void logSuccessMessage(String message) { + this.getSLF4JLogger().info("\u001B[32m✔ {}\u001B[0m", message); + } + + public void logErrorMessage(String message) { + this.getSLF4JLogger().info("\u001B[31m✔ {}\u001B[0m", message); + } + private void logLoadMessage() { - Logger log = getSLF4JLogger(); + Logger log = this.getSLF4JLogger(); String pluginVersion = getPluginMeta().getVersion(); String javaVersion = System.getProperty("java.version"); diff --git a/src/main/java/fr/openmc/core/bootstrap/features/Feature.java b/src/main/java/fr/openmc/core/bootstrap/features/Feature.java new file mode 100644 index 000000000..731fc9b85 --- /dev/null +++ b/src/main/java/fr/openmc/core/bootstrap/features/Feature.java @@ -0,0 +1,48 @@ +package fr.openmc.core.bootstrap.features; + +import com.j256.ormlite.support.ConnectionSource; +import fr.openmc.core.OMCPlugin; +import fr.openmc.core.bootstrap.features.types.DatabaseFeature; +import fr.openmc.core.bootstrap.features.types.NotInUnitTest; + +import java.sql.SQLException; + +public abstract class Feature { + protected boolean initialize = false; + + public void startInit() { + if (this instanceof NotInUnitTest && OMCPlugin.isUnitTestVersion()) { + OMCPlugin.getInstance().logSuccessMessage("Feature " + this.getClass().getSimpleName() + " non initialisée dans les Unit Tests"); + return; + } + try { + init(); + initialize = true; + OMCPlugin.getInstance().logSuccessMessage("Feature " + this.getClass().getSimpleName() + " initialisée correctement."); + } catch (Exception e) { + initialize = false; + OMCPlugin.getInstance().logSuccessMessage("Feature " + this.getClass().getSimpleName() + " non initialisée."); + throw e; + } + } + + public final void startDB(ConnectionSource connectionSource) throws SQLException { + if (this instanceof NotInUnitTest && OMCPlugin.isUnitTestVersion()) return; + if (this instanceof DatabaseFeature dbF) { + dbF.initDB(connectionSource); + } + } + + public final void startSave() { + if (!initialize) return; + if (this instanceof NotInUnitTest && OMCPlugin.isUnitTestVersion()) return; + save(); + } + + public final boolean isInitialized() { + return initialize; + } + + protected abstract void init(); + protected abstract void save(); +} diff --git a/src/main/java/fr/openmc/core/bootstrap/features/types/DatabaseFeature.java b/src/main/java/fr/openmc/core/bootstrap/features/types/DatabaseFeature.java new file mode 100644 index 000000000..093fabacc --- /dev/null +++ b/src/main/java/fr/openmc/core/bootstrap/features/types/DatabaseFeature.java @@ -0,0 +1,13 @@ +package fr.openmc.core.bootstrap.features.types; + +import com.j256.ormlite.support.ConnectionSource; + +import java.sql.SQLException; + +/** + * Interface permettant aux features d'initialiser leur base de données lors du démarrage du plugin. + */ +public interface DatabaseFeature { + void initDB(ConnectionSource connectionSource) throws SQLException; +} + 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 new file mode 100644 index 000000000..f8fb7acdc --- /dev/null +++ b/src/main/java/fr/openmc/core/bootstrap/features/types/LoadAfterItemsAdder.java @@ -0,0 +1,7 @@ +package fr.openmc.core.bootstrap.features.types; + +/** + * Charge la feature apres ItemsAdder + */ +public interface LoadAfterItemsAdder { } + diff --git a/src/main/java/fr/openmc/core/bootstrap/integration/DatabaseManager.java b/src/main/java/fr/openmc/core/bootstrap/integration/DatabaseManager.java new file mode 100644 index 000000000..2cd95e713 --- /dev/null +++ b/src/main/java/fr/openmc/core/bootstrap/integration/DatabaseManager.java @@ -0,0 +1,93 @@ +package fr.openmc.core.bootstrap.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.types.DatabaseFeature; +import lombok.Getter; +import org.bukkit.configuration.file.FileConfiguration; + +import java.nio.channels.ConnectionPendingException; +import java.sql.SQLException; + +public class DatabaseManager { + @Getter + private static ConnectionSource connectionSource; + + public static void init() { + try { + if (OMCPlugin.isUnitTestVersion()) { + Class.forName("org.h2.Driver"); + } else { + Class.forName("com.mysql.cj.jdbc.Driver"); + } + } catch (ClassNotFoundException e) { + OMCPlugin.getInstance().getSLF4JLogger().error("Database driver not found. Please ensure the MySQL or H2 driver is included in the classpath."); + throw new RuntimeException(e); + } + + // ormlite + try { + FileConfiguration config = OMCPlugin.getConfigs(); + String databaseUrl = config.getString("database.url"); + String username = config.getString("database.username"); + String password = config.getString("database.password"); + connectionSource = new JdbcPooledConnectionSource(databaseUrl, username, password); + + OMCPlugin.getInstance().REGISTRY_FEATURE.stream() + .filter(f -> f instanceof DatabaseFeature) + .forEach(f -> { + try { + ((DatabaseFeature) f).initDB(connectionSource); + } catch (SQLException e) { + OMCPlugin.getInstance().getSLF4JLogger().error("Failed to initialize the database connection.", e); + throw new RuntimeException(e); + } catch (ConnectionPendingException e) { + OMCPlugin.getInstance().getSLF4JLogger().error("Database connection is pending. Please check your database configuration."); + throw new RuntimeException(e); + } + }); + } catch (SQLException e) { + OMCPlugin.getInstance().getSLF4JLogger().error("Failed to initialize the database connection.", e); + throw new RuntimeException(e); + } catch (ConnectionPendingException e) { + OMCPlugin.getInstance().getSLF4JLogger().error("Database connection is pending. Please check your database configuration."); + throw new RuntimeException(e); + } + } + + /** + * Désactive les loggers venant de OrmLite (création de table ect...) + */ + public static class ShutUpOrmLite extends LocalLogBackend { + private final String classLabel; + + public ShutUpOrmLite(String classLabel) { + super(classLabel); + this.classLabel = classLabel; + } + + @Override + public boolean isLevelEnabled(Level level) { + return Level.INFO.isEnabled(level); + } + + @Override + public void log(Level level, String msg) { + if (classLabel.contains("com.j256.ormlite.table.TableUtils") || msg.contains("DaoManager created dao for class class")) + return; + + super.log(level, msg); + } + + @Override + public void log(Level level, String msg, Throwable throwable) { + if (classLabel.contains("com.j256.ormlite.table.TableUtils") || msg.contains("DaoManager created dao for class class")) + return; + + super.log(level, msg, throwable); + } + } +} diff --git a/src/main/java/fr/openmc/core/utils/errors/ErrorReporter.java b/src/main/java/fr/openmc/core/bootstrap/integration/ErrorReporter.java similarity index 97% rename from src/main/java/fr/openmc/core/utils/errors/ErrorReporter.java rename to src/main/java/fr/openmc/core/bootstrap/integration/ErrorReporter.java index 80405966e..639ee9ec7 100644 --- a/src/main/java/fr/openmc/core/utils/errors/ErrorReporter.java +++ b/src/main/java/fr/openmc/core/bootstrap/integration/ErrorReporter.java @@ -1,7 +1,7 @@ -package fr.openmc.core.utils.errors; +package fr.openmc.core.bootstrap.integration; import fr.openmc.core.OMCPlugin; -import fr.openmc.core.utils.DiscordWebhook; +import fr.openmc.core.utils.DiscordWebhookUtils; import org.bukkit.Bukkit; import java.io.OutputStream; @@ -152,7 +152,7 @@ private void handleException(List currentError) { discordMsg += "```"; } - DiscordWebhook.sendMessage(webhookUrl, discordMsg); + DiscordWebhookUtils.sendMessage(webhookUrl, discordMsg); } catch (Exception e) { originalErr.println("[ErrorReporter] Échec lors du traitement d'une erreur : " + e.getMessage()); diff --git a/src/main/java/fr/openmc/core/commands/admin/freeze/FreezeListener.java b/src/main/java/fr/openmc/core/commands/admin/freeze/FreezeListener.java index 9ef1c4ed1..c487184df 100644 --- a/src/main/java/fr/openmc/core/commands/admin/freeze/FreezeListener.java +++ b/src/main/java/fr/openmc/core/commands/admin/freeze/FreezeListener.java @@ -1,8 +1,8 @@ package fr.openmc.core.commands.admin.freeze; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; 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 559e41851..3ec73152a 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,10 @@ package fr.openmc.core.commands.admin.freeze; import fr.openmc.core.OMCPlugin; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.bootstrap.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; import net.kyori.adventure.text.Component; import org.bukkit.Bukkit; import org.bukkit.Location; @@ -13,15 +14,21 @@ import java.util.HashSet; import java.util.Set; -public class FreezeManager { +public class FreezeManager extends Feature { public static final Set FROZEN_PLAYERS = new HashSet<>(); private static Player player; - public static void init() { + @Override + public void init() { Bukkit.getServer().getPluginManager().registerEvents(new FreezeListener(), OMCPlugin.getInstance()); } - + + @Override + public void save() { + // nothing to save + } + /** * Freeze or unfreeze a player * diff --git a/src/main/java/fr/openmc/core/commands/fun/Diceroll.java b/src/main/java/fr/openmc/core/commands/fun/Diceroll.java index 8474864a6..9b3503fe8 100644 --- a/src/main/java/fr/openmc/core/commands/fun/Diceroll.java +++ b/src/main/java/fr/openmc/core/commands/fun/Diceroll.java @@ -1,8 +1,8 @@ package fr.openmc.core.commands.fun; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.entity.Player; import revxrsal.commands.annotation.Command; diff --git a/src/main/java/fr/openmc/core/commands/fun/Playtime.java b/src/main/java/fr/openmc/core/commands/fun/Playtime.java index a0dba9c08..58cd9dce3 100644 --- a/src/main/java/fr/openmc/core/commands/fun/Playtime.java +++ b/src/main/java/fr/openmc/core/commands/fun/Playtime.java @@ -1,10 +1,10 @@ package fr.openmc.core.commands.fun; -import fr.openmc.core.utils.DateUtils; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; -import fr.openmc.core.utils.translation.TranslationManager; +import fr.openmc.core.utils.text.DateUtils; +import fr.openmc.core.utils.text.TranslationManager; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.Statistic; import org.bukkit.entity.Player; diff --git a/src/main/java/fr/openmc/core/commands/utils/Cooldowns.java b/src/main/java/fr/openmc/core/commands/utils/Cooldowns.java index 9ae0d4a7c..e53c58acc 100644 --- a/src/main/java/fr/openmc/core/commands/utils/Cooldowns.java +++ b/src/main/java/fr/openmc/core/commands/utils/Cooldowns.java @@ -3,10 +3,10 @@ import fr.openmc.api.cooldown.DynamicCooldownManager; import fr.openmc.core.features.city.City; import fr.openmc.core.features.city.CityManager; -import fr.openmc.core.utils.DateUtils; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.DateUtils; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.entity.Player; import revxrsal.commands.annotation.Command; diff --git a/src/main/java/fr/openmc/core/commands/utils/RTPCommands.java b/src/main/java/fr/openmc/core/commands/utils/RTPCommands.java index acaa9990f..0817b508e 100644 --- a/src/main/java/fr/openmc/core/commands/utils/RTPCommands.java +++ b/src/main/java/fr/openmc/core/commands/utils/RTPCommands.java @@ -3,10 +3,10 @@ import fr.openmc.api.cooldown.DynamicCooldown; import fr.openmc.api.cooldown.DynamicCooldownManager; import fr.openmc.core.OMCPlugin; -import fr.openmc.core.utils.PlayerUtils; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.bukkit.PlayerUtils; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.Bukkit; import org.bukkit.Location; 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 6f5f061dd..a878a0912 100644 --- a/src/main/java/fr/openmc/core/commands/utils/Restart.java +++ b/src/main/java/fr/openmc/core/commands/utils/Restart.java @@ -3,10 +3,9 @@ import fr.openmc.core.OMCPlugin; import fr.openmc.core.features.city.City; import fr.openmc.core.features.city.CityManager; -import fr.openmc.core.features.displays.scoreboards.ScoreboardManager; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.TextDecoration; diff --git a/src/main/java/fr/openmc/core/commands/utils/SetSpawn.java b/src/main/java/fr/openmc/core/commands/utils/SetSpawn.java index c990913a6..346b0c40e 100644 --- a/src/main/java/fr/openmc/core/commands/utils/SetSpawn.java +++ b/src/main/java/fr/openmc/core/commands/utils/SetSpawn.java @@ -1,12 +1,11 @@ package fr.openmc.core.commands.utils; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.Location; import org.bukkit.entity.Player; - -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; import revxrsal.commands.annotation.Command; import revxrsal.commands.annotation.Description; import revxrsal.commands.bukkit.annotation.CommandPermission; diff --git a/src/main/java/fr/openmc/core/commands/utils/Spawn.java b/src/main/java/fr/openmc/core/commands/utils/Spawn.java index 858af82ac..5ee31abf5 100644 --- a/src/main/java/fr/openmc/core/commands/utils/Spawn.java +++ b/src/main/java/fr/openmc/core/commands/utils/Spawn.java @@ -1,11 +1,11 @@ package fr.openmc.core.commands.utils; import fr.openmc.core.commands.autocomplete.OnlinePlayerAutoComplete; -import fr.openmc.core.utils.PlayerUtils; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.MessagesManager.Message; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.bukkit.PlayerUtils; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.MessagesManager.Message; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.Location; import org.bukkit.command.CommandSender; 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 883c49797..4cb875cdf 100644 --- a/src/main/java/fr/openmc/core/commands/utils/SpawnManager.java +++ b/src/main/java/fr/openmc/core/commands/utils/SpawnManager.java @@ -1,6 +1,7 @@ package fr.openmc.core.commands.utils; import fr.openmc.core.OMCPlugin; +import fr.openmc.core.bootstrap.features.Feature; import lombok.Getter; import org.bukkit.Location; import org.bukkit.World; @@ -10,17 +11,23 @@ import java.io.File; import java.io.IOException; -public class SpawnManager { +public class SpawnManager extends Feature { private static File spawnFile; private static FileConfiguration spawnConfig; @Getter private static Location spawnLocation; - public static void init() { + @Override + public void init() { spawnFile = new File(OMCPlugin.getInstance().getDataFolder() + "/data", "spawn.yml"); loadSpawnConfig(); } + @Override + public void save() { + // nothing to save + } + private static void loadSpawnConfig() { if(!spawnFile.exists()) { spawnFile.getParentFile().mkdirs(); diff --git a/src/main/java/fr/openmc/core/disabled/corporation/commands/ShopCommand.java.bak b/src/main/java/fr/openmc/core/disabled/corporation/commands/ShopCommand.java.bak index ed1d099e4..8633a054e 100644 --- a/src/main/java/fr/openmc/core/disabled/corporation/commands/ShopCommand.java.bak +++ b/src/main/java/fr/openmc/core/disabled/corporation/commands/ShopCommand.java.bak @@ -13,7 +13,7 @@ import fr.openmc.core.disabled.corporation.shops.Shop; import fr.openmc.core.disabled.corporation.shops.ShopItem; import fr.openmc.core.disabled.corporation.shops.Supply; import fr.openmc.core.features.economy.EconomyManager; -import fr.openmc.core.utils.ItemUtils; +import fr.openmc.core.utils.bukkit.ItemUtils; import fr.openmc.core.utils.messages.MessageType; import fr.openmc.core.utils.messages.MessagesManager; import fr.openmc.core.utils.messages.Prefix; diff --git a/src/main/java/fr/openmc/core/disabled/corporation/company/Company.java.bak b/src/main/java/fr/openmc/core/disabled/corporation/company/Company.java.bak index 5afb5e601..f0a5c72f0 100644 --- a/src/main/java/fr/openmc/core/disabled/corporation/company/Company.java.bak +++ b/src/main/java/fr/openmc/core/disabled/corporation/company/Company.java.bak @@ -15,7 +15,7 @@ import fr.openmc.core.features.city.CityManager; import fr.openmc.core.features.city.CityPermission; import fr.openmc.core.features.economy.EconomyManager; import fr.openmc.core.utils.Queue; -import fr.openmc.core.utils.SkullUtils; +import fr.openmc.core.utils.bukkit.SkullUtils; import fr.openmc.core.utils.messages.MessageType; import fr.openmc.core.utils.messages.MessagesManager; import fr.openmc.core.utils.messages.Prefix; diff --git a/src/main/java/fr/openmc/core/disabled/corporation/manager/CompanyManager.java.bak b/src/main/java/fr/openmc/core/disabled/corporation/manager/CompanyManager.java.bak index fdf099154..b7211f95d 100644 --- a/src/main/java/fr/openmc/core/disabled/corporation/manager/CompanyManager.java.bak +++ b/src/main/java/fr/openmc/core/disabled/corporation/manager/CompanyManager.java.bak @@ -24,7 +24,7 @@ import fr.openmc.core.disabled.corporation.shops.Supply; import fr.openmc.core.features.city.City; import fr.openmc.core.features.city.CityManager; import fr.openmc.core.utils.Queue; -import fr.openmc.core.utils.database.DatabaseManager; +import fr.openmc.core.bootstrap.integration.DatabaseManager; import fr.openmc.core.utils.serializer.BukkitSerializer; import lombok.Getter; import lombok.SneakyThrows; diff --git a/src/main/java/fr/openmc/core/disabled/corporation/menu/company/CompanyBaltopMenu.java.bak b/src/main/java/fr/openmc/core/disabled/corporation/menu/company/CompanyBaltopMenu.java.bak index b8a4474a8..02045a289 100644 --- a/src/main/java/fr/openmc/core/disabled/corporation/menu/company/CompanyBaltopMenu.java.bak +++ b/src/main/java/fr/openmc/core/disabled/corporation/menu/company/CompanyBaltopMenu.java.bak @@ -9,7 +9,7 @@ import fr.openmc.core.disabled.corporation.data.MerchantData; import fr.openmc.core.disabled.corporation.manager.CompanyManager; import fr.openmc.core.features.city.CityPermission; import fr.openmc.core.features.economy.EconomyManager; -import fr.openmc.core.utils.SkullUtils; +import fr.openmc.core.utils.bukkit.SkullUtils; import net.kyori.adventure.text.Component; import org.bukkit.Bukkit; import org.bukkit.Material; diff --git a/src/main/java/fr/openmc/core/disabled/corporation/menu/company/CompanyMenu.java.bak b/src/main/java/fr/openmc/core/disabled/corporation/menu/company/CompanyMenu.java.bak index 916e4db31..18ebfb975 100644 --- a/src/main/java/fr/openmc/core/disabled/corporation/menu/company/CompanyMenu.java.bak +++ b/src/main/java/fr/openmc/core/disabled/corporation/menu/company/CompanyMenu.java.bak @@ -9,7 +9,7 @@ import fr.openmc.core.disabled.corporation.company.Company; import fr.openmc.core.disabled.corporation.data.MerchantData; import fr.openmc.core.features.economy.EconomyManager; import fr.openmc.core.items.CustomItemRegistry; -import fr.openmc.core.utils.SkullUtils; +import fr.openmc.core.utils.bukkit.SkullUtils; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/src/main/java/fr/openmc/core/disabled/corporation/menu/shop/ShopMenu.java.bak b/src/main/java/fr/openmc/core/disabled/corporation/menu/shop/ShopMenu.java.bak index dc23e139a..ecff74e22 100644 --- a/src/main/java/fr/openmc/core/disabled/corporation/menu/shop/ShopMenu.java.bak +++ b/src/main/java/fr/openmc/core/disabled/corporation/menu/shop/ShopMenu.java.bak @@ -13,7 +13,7 @@ import fr.openmc.core.disabled.corporation.shops.Shop; import fr.openmc.core.disabled.corporation.shops.ShopItem; import fr.openmc.core.features.economy.EconomyManager; import fr.openmc.core.items.CustomItemRegistry; -import fr.openmc.core.utils.ItemUtils; +import fr.openmc.core.utils.bukkit.ItemUtils; import fr.openmc.core.utils.messages.MessageType; import fr.openmc.core.utils.messages.MessagesManager; import fr.openmc.core.utils.messages.Prefix; diff --git a/src/main/java/fr/openmc/core/disabled/corporation/menu/shop/ShopSearchMenu.java.bak b/src/main/java/fr/openmc/core/disabled/corporation/menu/shop/ShopSearchMenu.java.bak index 8834adecf..f5f9ff662 100644 --- a/src/main/java/fr/openmc/core/disabled/corporation/menu/shop/ShopSearchMenu.java.bak +++ b/src/main/java/fr/openmc/core/disabled/corporation/menu/shop/ShopSearchMenu.java.bak @@ -1,7 +1,7 @@ package fr.openmc.core.disabled.corporation.menu.shop; import dev.lone.itemsadder.api.FontImages.FontImageWrapper; -import fr.openmc.api.input.DialogInput; +import fr.openmc.api.input.dialog.DialogInput; import fr.openmc.api.menulib.PaginatedMenu; import fr.openmc.api.menulib.utils.InventorySize; import fr.openmc.api.menulib.utils.ItemBuilder; @@ -11,7 +11,7 @@ import fr.openmc.core.disabled.corporation.manager.CompanyManager; import fr.openmc.core.disabled.corporation.manager.ShopBlocksManager; import fr.openmc.core.disabled.corporation.shops.Shop; import fr.openmc.core.items.CustomItemRegistry; -import fr.openmc.core.utils.ItemUtils; +import fr.openmc.core.utils.bukkit.ItemUtils; import fr.openmc.core.utils.messages.MessageType; import fr.openmc.core.utils.messages.MessagesManager; import fr.openmc.core.utils.messages.Prefix; @@ -30,7 +30,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import static fr.openmc.core.utils.InputUtils.MAX_LENGTH; +import static fr.openmc.core.utils.text.InputUtils.MAX_LENGTH; public class ShopSearchMenu extends PaginatedMenu { diff --git a/src/main/java/fr/openmc/core/disabled/corporation/menu/shop/ShopStocksMenu.java.bak b/src/main/java/fr/openmc/core/disabled/corporation/menu/shop/ShopStocksMenu.java.bak index 7f48f217b..c62873176 100644 --- a/src/main/java/fr/openmc/core/disabled/corporation/menu/shop/ShopStocksMenu.java.bak +++ b/src/main/java/fr/openmc/core/disabled/corporation/menu/shop/ShopStocksMenu.java.bak @@ -11,7 +11,7 @@ import fr.openmc.core.disabled.corporation.shops.ShopItem; import fr.openmc.core.disabled.corporation.shops.Supply; import fr.openmc.core.features.economy.EconomyManager; import fr.openmc.core.items.CustomItemRegistry; -import fr.openmc.core.utils.ItemUtils; +import fr.openmc.core.utils.bukkit.ItemUtils; import fr.openmc.core.utils.messages.MessageType; import fr.openmc.core.utils.messages.MessagesManager; import fr.openmc.core.utils.messages.Prefix; diff --git a/src/main/java/fr/openmc/core/disabled/corporation/shops/Shop.java.bak b/src/main/java/fr/openmc/core/disabled/corporation/shops/Shop.java.bak index 6e2cae152..4b1f88b84 100644 --- a/src/main/java/fr/openmc/core/disabled/corporation/shops/Shop.java.bak +++ b/src/main/java/fr/openmc/core/disabled/corporation/shops/Shop.java.bak @@ -7,7 +7,7 @@ import fr.openmc.core.disabled.corporation.manager.CompanyManager; import fr.openmc.core.disabled.corporation.manager.ShopBlocksManager; import fr.openmc.core.features.economy.EconomyManager; import fr.openmc.core.utils.cache.CacheOfflinePlayer; -import fr.openmc.core.utils.ItemUtils; +import fr.openmc.core.utils.bukkit.ItemUtils; import fr.openmc.core.utils.messages.MessageType; import fr.openmc.core.utils.messages.MessagesManager; import fr.openmc.core.utils.messages.Prefix; diff --git a/src/main/java/fr/openmc/core/disabled/corporation/shops/ShopItem.java.bak b/src/main/java/fr/openmc/core/disabled/corporation/shops/ShopItem.java.bak index 0308f61a7..dfd4fe628 100644 --- a/src/main/java/fr/openmc/core/disabled/corporation/shops/ShopItem.java.bak +++ b/src/main/java/fr/openmc/core/disabled/corporation/shops/ShopItem.java.bak @@ -1,6 +1,6 @@ package fr.openmc.core.disabled.corporation.shops; -import fr.openmc.core.utils.ItemUtils; +import fr.openmc.core.utils.bukkit.ItemUtils; import lombok.Getter; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; diff --git a/src/main/java/fr/openmc/core/events/ArmorEquipEvent.java b/src/main/java/fr/openmc/core/events/ArmorEquipEvent.java index c056d2230..b6f0e112b 100644 --- a/src/main/java/fr/openmc/core/events/ArmorEquipEvent.java +++ b/src/main/java/fr/openmc/core/events/ArmorEquipEvent.java @@ -1,6 +1,6 @@ package fr.openmc.core.events; -import fr.openmc.core.utils.ArmorType; +import fr.openmc.core.listeners.ArmorListener; import lombok.Getter; import lombok.Setter; import org.bukkit.entity.Player; @@ -61,4 +61,40 @@ public enum EquipMethod { BROKE, DEATH } + + public enum ArmorType { + HELMET(5), + CHESTPLATE(6), + LEGGINGS(7), + BOOTS(8), + ; + + @Getter + private final int slot; + + /** + * Constructor for ArmorType enum. + * + * @param slot The inventory slot associated with the armor type. + */ + ArmorType(int slot) { + this.slot = slot; + } + + /** + * Checks if the item match with the armor type. + * + * @param itemStack The ItemStack to check. + * @return true if the item matches an armor type, false otherwise. + */ + public static ArmorType match(final ItemStack itemStack) { + if(ArmorListener.isAirOrNull(itemStack)) return null; + String type = itemStack.getType().name(); + if(type.endsWith("_HELMET") || type.endsWith("_SKULL") || type.endsWith("_HEAD")) return HELMET; + else if(type.endsWith("_CHESTPLATE") || type.equals("ELYTRA")) return CHESTPLATE; + else if(type.endsWith("_LEGGINGS")) return LEGGINGS; + else if(type.endsWith("_BOOTS")) return BOOTS; + else return null; + } + } } 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 84d2f2b1f..10420f970 100644 --- a/src/main/java/fr/openmc/core/features/adminshop/AdminShopManager.java +++ b/src/main/java/fr/openmc/core/features/adminshop/AdminShopManager.java @@ -2,14 +2,15 @@ import fr.openmc.api.menulib.Menu; import fr.openmc.core.OMCPlugin; +import fr.openmc.core.bootstrap.features.Feature; 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.utils.ItemUtils; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.bukkit.ItemUtils; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.Bukkit; import org.bukkit.entity.Player; @@ -24,7 +25,7 @@ /** * Manages the admin shop system including items, categories, and player interactions. */ -public class AdminShopManager { +public class AdminShopManager extends Feature { public static final Map categories = new HashMap<>(); public static final Map> items = new HashMap<>(); // Category -> {ShopID -> ShopItem} public static final Map currentCategory = new HashMap<>(); @@ -34,11 +35,17 @@ public class AdminShopManager { /** * Initializes the AdminShopManager by loading the configuration. */ - public static void init() { + @Override + public void init() { adminShopYAML = new AdminShopYAML(); adminShopYAML.loadConfig(); } + @Override + public void save() { + // nothing to save + } + /** * Opens the confirmation menu for buying an item. * diff --git a/src/main/java/fr/openmc/core/features/adminshop/AdminShopYAML.java b/src/main/java/fr/openmc/core/features/adminshop/AdminShopYAML.java index dd7c1f0a0..cc5cefd76 100644 --- a/src/main/java/fr/openmc/core/features/adminshop/AdminShopYAML.java +++ b/src/main/java/fr/openmc/core/features/adminshop/AdminShopYAML.java @@ -1,7 +1,7 @@ package fr.openmc.core.features.adminshop; import fr.openmc.core.OMCPlugin; -import fr.openmc.core.utils.ItemUtils; +import fr.openmc.core.utils.bukkit.ItemUtils; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.TextDecoration; import net.kyori.adventure.text.minimessage.MiniMessage; diff --git a/src/main/java/fr/openmc/core/features/adminshop/menus/ColorVariantsMenu.java b/src/main/java/fr/openmc/core/features/adminshop/menus/ColorVariantsMenu.java index 8f2f604d7..8aa4e417b 100644 --- a/src/main/java/fr/openmc/core/features/adminshop/menus/ColorVariantsMenu.java +++ b/src/main/java/fr/openmc/core/features/adminshop/menus/ColorVariantsMenu.java @@ -8,7 +8,7 @@ import fr.openmc.core.features.adminshop.AdminShopUtils; import fr.openmc.core.features.adminshop.ShopItem; import fr.openmc.core.registry.items.CustomItemRegistry; -import fr.openmc.core.utils.ItemUtils; +import fr.openmc.core.utils.bukkit.ItemUtils; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.TextDecoration; diff --git a/src/main/java/fr/openmc/core/features/adminshop/menus/ConfirmMenu.java b/src/main/java/fr/openmc/core/features/adminshop/menus/ConfirmMenu.java index 413c89c9c..eb0c77539 100644 --- a/src/main/java/fr/openmc/core/features/adminshop/menus/ConfirmMenu.java +++ b/src/main/java/fr/openmc/core/features/adminshop/menus/ConfirmMenu.java @@ -1,7 +1,7 @@ package fr.openmc.core.features.adminshop.menus; import dev.lone.itemsadder.api.FontImages.FontImageWrapper; -import fr.openmc.api.input.DialogInput; +import fr.openmc.api.input.dialog.DialogInput; import fr.openmc.api.menulib.Menu; import fr.openmc.api.menulib.utils.InventorySize; import fr.openmc.api.menulib.utils.ItemBuilder; @@ -9,7 +9,7 @@ import fr.openmc.core.features.adminshop.ShopItem; import fr.openmc.core.features.economy.EconomyManager; import fr.openmc.core.registry.items.CustomItemRegistry; -import fr.openmc.core.utils.ItemUtils; +import fr.openmc.core.utils.bukkit.ItemUtils; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.TextDecoration; diff --git a/src/main/java/fr/openmc/core/features/adminshop/menus/LeavesVariantsMenu.java b/src/main/java/fr/openmc/core/features/adminshop/menus/LeavesVariantsMenu.java index 78818e4e6..acb96d2f6 100644 --- a/src/main/java/fr/openmc/core/features/adminshop/menus/LeavesVariantsMenu.java +++ b/src/main/java/fr/openmc/core/features/adminshop/menus/LeavesVariantsMenu.java @@ -8,7 +8,7 @@ import fr.openmc.core.features.adminshop.AdminShopUtils; import fr.openmc.core.features.adminshop.ShopItem; import fr.openmc.core.registry.items.CustomItemRegistry; -import fr.openmc.core.utils.ItemUtils; +import fr.openmc.core.utils.bukkit.ItemUtils; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.TextDecoration; diff --git a/src/main/java/fr/openmc/core/features/adminshop/menus/LogVariantsMenu.java b/src/main/java/fr/openmc/core/features/adminshop/menus/LogVariantsMenu.java index d45f4c3c8..e95d97489 100644 --- a/src/main/java/fr/openmc/core/features/adminshop/menus/LogVariantsMenu.java +++ b/src/main/java/fr/openmc/core/features/adminshop/menus/LogVariantsMenu.java @@ -8,7 +8,7 @@ import fr.openmc.core.features.adminshop.AdminShopUtils; import fr.openmc.core.features.adminshop.ShopItem; import fr.openmc.core.registry.items.CustomItemRegistry; -import fr.openmc.core.utils.ItemUtils; +import fr.openmc.core.utils.bukkit.ItemUtils; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.TextDecoration; diff --git a/src/main/java/fr/openmc/core/features/analytics/AnalyticsManager.java b/src/main/java/fr/openmc/core/features/analytics/AnalyticsManager.java index b191e741f..8010045c2 100644 --- a/src/main/java/fr/openmc/core/features/analytics/AnalyticsManager.java +++ b/src/main/java/fr/openmc/core/features/analytics/AnalyticsManager.java @@ -6,6 +6,8 @@ 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.DatabaseFeature; import fr.openmc.core.features.analytics.models.Statistic; import org.bukkit.Bukkit; @@ -13,10 +15,21 @@ import java.util.List; import java.util.UUID; -public class AnalyticsManager { +public class AnalyticsManager extends Feature implements DatabaseFeature { static Dao statsDao; - public static void initDB(ConnectionSource connectionSource) throws SQLException { + @Override + protected void init() { + // nothing to init + } + + @Override + protected void save() { + // nothing to save + } + + @Override + public void initDB(ConnectionSource connectionSource) throws SQLException { TableUtils.createTableIfNotExists(connectionSource, Statistic.class); statsDao = DaoManager.createDao(connectionSource, Statistic.class); } diff --git a/src/main/java/fr/openmc/core/features/animations/AnimationsManager.java b/src/main/java/fr/openmc/core/features/animations/AnimationsManager.java index 989acc8ef..f9760f145 100644 --- a/src/main/java/fr/openmc/core/features/animations/AnimationsManager.java +++ b/src/main/java/fr/openmc/core/features/animations/AnimationsManager.java @@ -5,6 +5,8 @@ import com.google.gson.JsonObject; import com.google.gson.JsonParser; import fr.openmc.core.OMCPlugin; +import fr.openmc.core.bootstrap.features.Feature; +import fr.openmc.core.bootstrap.features.types.NotInUnitTest; import fr.openmc.core.features.animations.listeners.EmoteListener; import fr.openmc.core.features.animations.listeners.PlayerFinishJoiningListener; import org.bukkit.util.Vector; @@ -17,9 +19,10 @@ import java.nio.file.Files; import java.util.Map; -public class AnimationsManager { +public class AnimationsManager extends Feature implements NotInUnitTest { - public static void init() { + @Override + public void init() { OMCPlugin plugin = OMCPlugin.getInstance(); saveAllAnimation(plugin); @@ -34,6 +37,11 @@ public static void init() { } } + @Override + public void save() { + // nothing to save + } + public static JsonObject loadAnimation(OMCPlugin plugin, String ressourcePath) { File file = new File(plugin.getDataFolder(), ressourcePath); if (!file.exists()) { diff --git a/src/main/java/fr/openmc/core/features/city/ChunkDataCache.java b/src/main/java/fr/openmc/core/features/city/ChunkDataCache.java index 205914ccd..1f7534ed6 100644 --- a/src/main/java/fr/openmc/core/features/city/ChunkDataCache.java +++ b/src/main/java/fr/openmc/core/features/city/ChunkDataCache.java @@ -1,7 +1,7 @@ package fr.openmc.core.features.city; -import fr.openmc.core.utils.ChunkInfo; -import fr.openmc.core.utils.ChunkPos; +import fr.openmc.core.utils.world.chunk.ChunkInfo; +import fr.openmc.core.utils.world.chunk.ChunkPos; import java.util.Map; diff --git a/src/main/java/fr/openmc/core/features/city/City.java b/src/main/java/fr/openmc/core/features/city/City.java index 0f53af7e2..00e66dead 100644 --- a/src/main/java/fr/openmc/core/features/city/City.java +++ b/src/main/java/fr/openmc/core/features/city/City.java @@ -18,12 +18,12 @@ import fr.openmc.core.features.city.sub.rank.CityRankManager; import fr.openmc.core.features.city.sub.war.War; import fr.openmc.core.features.city.sub.war.WarManager; -import fr.openmc.core.utils.ChunkPos; -import fr.openmc.core.utils.DateUtils; import fr.openmc.core.utils.cache.CacheOfflinePlayer; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.DateUtils; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; +import fr.openmc.core.utils.world.chunk.ChunkPos; import lombok.Getter; import lombok.Setter; import net.kyori.adventure.text.Component; diff --git a/src/main/java/fr/openmc/core/features/city/CityChatManager.java b/src/main/java/fr/openmc/core/features/city/CityChatManager.java index 0ed0b1ebd..4d1eee3b6 100644 --- a/src/main/java/fr/openmc/core/features/city/CityChatManager.java +++ b/src/main/java/fr/openmc/core/features/city/CityChatManager.java @@ -1,8 +1,8 @@ package fr.openmc.core.features.city; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; import org.bukkit.Bukkit; diff --git a/src/main/java/fr/openmc/core/features/city/CityManager.java b/src/main/java/fr/openmc/core/features/city/CityManager.java index 43c898660..dba2463ca 100644 --- a/src/main/java/fr/openmc/core/features/city/CityManager.java +++ b/src/main/java/fr/openmc/core/features/city/CityManager.java @@ -10,6 +10,9 @@ import fr.openmc.api.cooldown.DynamicCooldownManager; import fr.openmc.core.CommandsManager; import fr.openmc.core.OMCPlugin; +import fr.openmc.core.bootstrap.features.Feature; +import fr.openmc.core.bootstrap.features.types.DatabaseFeature; +import fr.openmc.core.bootstrap.features.types.LoadAfterItemsAdder; import fr.openmc.core.features.city.commands.*; import fr.openmc.core.features.city.events.CityDeleteEvent; import fr.openmc.core.features.city.listeners.CityChatListener; @@ -26,8 +29,8 @@ import fr.openmc.core.features.city.sub.statistics.CityStatisticsManager; import fr.openmc.core.features.city.sub.war.WarManager; import fr.openmc.core.features.city.view.CityViewManager; -import fr.openmc.core.utils.ChunkPos; import fr.openmc.core.utils.cache.CacheOfflinePlayer; +import fr.openmc.core.utils.world.chunk.ChunkPos; import org.bukkit.Bukkit; import org.bukkit.Chunk; import org.bukkit.entity.Player; @@ -37,13 +40,14 @@ import java.sql.SQLException; import java.util.*; -public class CityManager { +public class CityManager extends Feature implements DatabaseFeature, LoadAfterItemsAdder { private static final Map cities = new HashMap<>(); public static final Map citiesByName = new HashMap<>(); public static final Map playerCities = new HashMap<>(); private static final Map claimedChunks = new HashMap<>(); - public static void init() { + @Override + public void init() { loadCities(); CommandsManager.getHandler().register( @@ -73,13 +77,33 @@ public static void init() { CityMilestoneManager.init(); } + @Override + public void save() { + // - War + WarManager.saveWarHistories(); + + // - CityStatistics + CityStatisticsManager.saveCityStatistics(); + + // - Notation des Villes + NotationManager.saveNotations(); + + // - Maires + MayorManager.saveMayorConstant(); + MayorManager.savePlayersVote(); + MayorManager.saveMayorCandidates(); + MayorManager.saveCityMayors(); + MayorManager.saveCityLaws(); + } + private static Dao citiesDao; private static Dao membersDao; private static Dao permissionsDao; private static Dao claimsDao; private static Dao chestsDao; - public static void initDB(ConnectionSource connectionSource) throws SQLException { + @Override + public void initDB(ConnectionSource connectionSource) throws SQLException { TableUtils.createTableIfNotExists(connectionSource, DBCity.class); citiesDao = DaoManager.createDao(connectionSource, DBCity.class); @@ -94,6 +118,12 @@ public static void initDB(ConnectionSource connectionSource) throws SQLException TableUtils.createTableIfNotExists(connectionSource, DBCityChest.class); chestsDao = DaoManager.createDao(connectionSource, DBCityChest.class); + + WarManager.initDB(connectionSource); + NotationManager.initDB(connectionSource); + MayorManager.initDB(connectionSource); + CityRankManager.initDB(connectionSource); + CityStatisticsManager.initDB(connectionSource); } // ==================== Database Methods ==================== diff --git a/src/main/java/fr/openmc/core/features/city/ProtectionsManager.java b/src/main/java/fr/openmc/core/features/city/ProtectionsManager.java index c5d174f63..68556fca4 100644 --- a/src/main/java/fr/openmc/core/features/city/ProtectionsManager.java +++ b/src/main/java/fr/openmc/core/features/city/ProtectionsManager.java @@ -3,9 +3,9 @@ import fr.openmc.core.OMCPlugin; import fr.openmc.core.features.city.listeners.protections.*; import fr.openmc.core.features.city.sub.war.War; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.Location; import org.bukkit.entity.Entity; diff --git a/src/main/java/fr/openmc/core/features/city/actions/CityChangeAction.java b/src/main/java/fr/openmc/core/features/city/actions/CityChangeAction.java index b835fb6f2..e561ce6c3 100644 --- a/src/main/java/fr/openmc/core/features/city/actions/CityChangeAction.java +++ b/src/main/java/fr/openmc/core/features/city/actions/CityChangeAction.java @@ -10,10 +10,10 @@ import fr.openmc.core.features.city.sub.mascots.models.Mascot; import fr.openmc.core.features.city.sub.mascots.models.MascotsLevels; import fr.openmc.core.features.city.sub.milestone.rewards.FeaturesRewards; -import fr.openmc.core.utils.DateUtils; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.DateUtils; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.NamespacedKey; import org.bukkit.attribute.Attribute; diff --git a/src/main/java/fr/openmc/core/features/city/actions/CityChestAction.java b/src/main/java/fr/openmc/core/features/city/actions/CityChestAction.java index 5a9067a7a..8006c5236 100644 --- a/src/main/java/fr/openmc/core/features/city/actions/CityChestAction.java +++ b/src/main/java/fr/openmc/core/features/city/actions/CityChestAction.java @@ -2,10 +2,10 @@ import fr.openmc.core.features.city.City; import fr.openmc.core.features.city.conditions.CityChestConditions; -import fr.openmc.core.utils.ItemUtils; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.bukkit.ItemUtils; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.entity.Player; diff --git a/src/main/java/fr/openmc/core/features/city/actions/CityClaimAction.java b/src/main/java/fr/openmc/core/features/city/actions/CityClaimAction.java index 91ad3e19e..f0b491a05 100644 --- a/src/main/java/fr/openmc/core/features/city/actions/CityClaimAction.java +++ b/src/main/java/fr/openmc/core/features/city/actions/CityClaimAction.java @@ -5,11 +5,11 @@ import fr.openmc.core.features.city.CityManager; import fr.openmc.core.features.city.conditions.CityClaimCondition; import fr.openmc.core.features.economy.EconomyManager; -import fr.openmc.core.utils.ChunkPos; -import fr.openmc.core.utils.ItemUtils; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.bukkit.ItemUtils; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; +import fr.openmc.core.utils.world.chunk.ChunkPos; import net.kyori.adventure.text.Component; import org.bukkit.Chunk; import org.bukkit.entity.Player; diff --git a/src/main/java/fr/openmc/core/features/city/actions/CityCreateAction.java b/src/main/java/fr/openmc/core/features/city/actions/CityCreateAction.java index 47d0a392b..4186f1064 100644 --- a/src/main/java/fr/openmc/core/features/city/actions/CityCreateAction.java +++ b/src/main/java/fr/openmc/core/features/city/actions/CityCreateAction.java @@ -13,10 +13,10 @@ import fr.openmc.core.features.economy.EconomyManager; import fr.openmc.core.registry.items.CustomItem; import fr.openmc.core.registry.items.CustomItemRegistry; -import fr.openmc.core.utils.ItemUtils; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.bukkit.ItemUtils; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.Chunk; import org.bukkit.Location; diff --git a/src/main/java/fr/openmc/core/features/city/actions/CityDeleteAction.java b/src/main/java/fr/openmc/core/features/city/actions/CityDeleteAction.java index 7d8076ac0..99bb30540 100644 --- a/src/main/java/fr/openmc/core/features/city/actions/CityDeleteAction.java +++ b/src/main/java/fr/openmc/core/features/city/actions/CityDeleteAction.java @@ -5,9 +5,9 @@ import fr.openmc.core.features.city.City; import fr.openmc.core.features.city.CityManager; import fr.openmc.core.features.city.conditions.CityManageConditions; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.Bukkit; import org.bukkit.entity.Player; diff --git a/src/main/java/fr/openmc/core/features/city/actions/CityKickAction.java b/src/main/java/fr/openmc/core/features/city/actions/CityKickAction.java index c3954618c..99b67052e 100644 --- a/src/main/java/fr/openmc/core/features/city/actions/CityKickAction.java +++ b/src/main/java/fr/openmc/core/features/city/actions/CityKickAction.java @@ -3,9 +3,9 @@ import fr.openmc.core.features.city.City; import fr.openmc.core.features.city.CityManager; import fr.openmc.core.features.city.conditions.CityKickCondition; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.OfflinePlayer; import org.bukkit.entity.Player; diff --git a/src/main/java/fr/openmc/core/features/city/actions/CityLeaveAction.java b/src/main/java/fr/openmc/core/features/city/actions/CityLeaveAction.java index 832209df9..b4fb7cbba 100644 --- a/src/main/java/fr/openmc/core/features/city/actions/CityLeaveAction.java +++ b/src/main/java/fr/openmc/core/features/city/actions/CityLeaveAction.java @@ -3,9 +3,9 @@ import fr.openmc.core.features.city.City; import fr.openmc.core.features.city.CityManager; import fr.openmc.core.features.city.conditions.CityLeaveCondition; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.Bukkit; import org.bukkit.entity.Player; diff --git a/src/main/java/fr/openmc/core/features/city/actions/CityTransferAction.java b/src/main/java/fr/openmc/core/features/city/actions/CityTransferAction.java index f846769c8..6c1f1a003 100644 --- a/src/main/java/fr/openmc/core/features/city/actions/CityTransferAction.java +++ b/src/main/java/fr/openmc/core/features/city/actions/CityTransferAction.java @@ -5,9 +5,9 @@ import fr.openmc.core.features.city.CityPermission; import fr.openmc.core.features.city.conditions.CityManageConditions; import fr.openmc.core.utils.cache.CacheOfflinePlayer; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.OfflinePlayer; import org.bukkit.entity.Player; diff --git a/src/main/java/fr/openmc/core/features/city/actions/CityUnclaimAction.java b/src/main/java/fr/openmc/core/features/city/actions/CityUnclaimAction.java index 645c34a33..6e0fc9b26 100644 --- a/src/main/java/fr/openmc/core/features/city/actions/CityUnclaimAction.java +++ b/src/main/java/fr/openmc/core/features/city/actions/CityUnclaimAction.java @@ -4,10 +4,10 @@ import fr.openmc.core.features.city.CityManager; import fr.openmc.core.features.economy.EconomyManager; import fr.openmc.core.registry.items.CustomItemRegistry; -import fr.openmc.core.utils.ItemUtils; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.bukkit.ItemUtils; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.World; import org.bukkit.entity.Player; diff --git a/src/main/java/fr/openmc/core/features/city/commands/AdminCityCommands.java b/src/main/java/fr/openmc/core/features/city/commands/AdminCityCommands.java index 7f63c0d59..9f8f1fb48 100644 --- a/src/main/java/fr/openmc/core/features/city/commands/AdminCityCommands.java +++ b/src/main/java/fr/openmc/core/features/city/commands/AdminCityCommands.java @@ -9,9 +9,9 @@ import fr.openmc.core.features.city.commands.autocomplete.CityNameAutoComplete; import fr.openmc.core.features.city.menu.list.CityListDetailsMenu; import fr.openmc.core.features.economy.EconomyManager; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.event.ClickEvent; import net.kyori.adventure.text.format.NamedTextColor; diff --git a/src/main/java/fr/openmc/core/features/city/commands/CityCommands.java b/src/main/java/fr/openmc/core/features/city/commands/CityCommands.java index 23f6d6e05..4b2020e8b 100644 --- a/src/main/java/fr/openmc/core/features/city/commands/CityCommands.java +++ b/src/main/java/fr/openmc/core/features/city/commands/CityCommands.java @@ -1,7 +1,7 @@ package fr.openmc.core.features.city.commands; import fr.openmc.api.chronometer.Chronometer; -import fr.openmc.api.input.DialogInput; +import fr.openmc.api.input.dialog.DialogInput; import fr.openmc.core.features.city.City; import fr.openmc.core.features.city.CityManager; import fr.openmc.core.features.city.actions.*; @@ -14,17 +14,17 @@ import fr.openmc.core.features.city.menu.list.CityListDetailsMenu; import fr.openmc.core.features.city.menu.list.CityListMenu; import fr.openmc.core.features.city.menu.main.CityMenu; -import fr.openmc.core.utils.InputUtils; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.InputUtils; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.OfflinePlayer; import org.bukkit.entity.Player; import revxrsal.commands.annotation.*; import revxrsal.commands.bukkit.annotation.CommandPermission; -import static fr.openmc.core.utils.InputUtils.MAX_LENGTH_CITY; +import static fr.openmc.core.utils.text.InputUtils.MAX_LENGTH_CITY; @Command({"ville", "city"}) public class CityCommands { diff --git a/src/main/java/fr/openmc/core/features/city/commands/CityInviteCommands.java b/src/main/java/fr/openmc/core/features/city/commands/CityInviteCommands.java index 6853bfbc8..94e6951ed 100644 --- a/src/main/java/fr/openmc/core/features/city/commands/CityInviteCommands.java +++ b/src/main/java/fr/openmc/core/features/city/commands/CityInviteCommands.java @@ -4,9 +4,9 @@ import fr.openmc.core.features.city.City; import fr.openmc.core.features.city.CityManager; import fr.openmc.core.features.city.conditions.CityInviteConditions; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.event.ClickEvent; import net.kyori.adventure.text.event.HoverEvent; diff --git a/src/main/java/fr/openmc/core/features/city/commands/CityPermsCommands.java b/src/main/java/fr/openmc/core/features/city/commands/CityPermsCommands.java index b8ce4d376..3f7cd2b2e 100644 --- a/src/main/java/fr/openmc/core/features/city/commands/CityPermsCommands.java +++ b/src/main/java/fr/openmc/core/features/city/commands/CityPermsCommands.java @@ -7,9 +7,9 @@ import fr.openmc.core.features.city.commands.autocomplete.CityPermissionsAutoComplete; import fr.openmc.core.features.city.conditions.CityPermsConditions; import fr.openmc.core.features.city.menu.CityPermsMenu; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.OfflinePlayer; import org.bukkit.entity.Player; diff --git a/src/main/java/fr/openmc/core/features/city/commands/CityTopCommands.java b/src/main/java/fr/openmc/core/features/city/commands/CityTopCommands.java index c2fd0ef7c..ee68cc8e1 100644 --- a/src/main/java/fr/openmc/core/features/city/commands/CityTopCommands.java +++ b/src/main/java/fr/openmc/core/features/city/commands/CityTopCommands.java @@ -3,9 +3,9 @@ import fr.openmc.core.features.city.City; import fr.openmc.core.features.city.CityManager; import fr.openmc.core.features.city.menu.CityTopMenu; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.entity.Player; import revxrsal.commands.annotation.Command; diff --git a/src/main/java/fr/openmc/core/features/city/conditions/CityChestConditions.java b/src/main/java/fr/openmc/core/features/city/conditions/CityChestConditions.java index 6e86df250..c8542915e 100644 --- a/src/main/java/fr/openmc/core/features/city/conditions/CityChestConditions.java +++ b/src/main/java/fr/openmc/core/features/city/conditions/CityChestConditions.java @@ -6,10 +6,10 @@ import fr.openmc.core.features.city.sub.milestone.rewards.FeaturesRewards; import fr.openmc.core.features.economy.EconomyManager; import fr.openmc.core.registry.items.CustomItemRegistry; -import fr.openmc.core.utils.ItemUtils; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.bukkit.ItemUtils; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.Bukkit; import org.bukkit.entity.Player; diff --git a/src/main/java/fr/openmc/core/features/city/conditions/CityClaimCondition.java b/src/main/java/fr/openmc/core/features/city/conditions/CityClaimCondition.java index 67353d2c1..38ba0d95a 100644 --- a/src/main/java/fr/openmc/core/features/city/conditions/CityClaimCondition.java +++ b/src/main/java/fr/openmc/core/features/city/conditions/CityClaimCondition.java @@ -5,10 +5,10 @@ import fr.openmc.core.features.city.actions.CityClaimAction; import fr.openmc.core.features.economy.EconomyManager; import fr.openmc.core.registry.items.CustomItemRegistry; -import fr.openmc.core.utils.ItemUtils; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.bukkit.ItemUtils; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.TextDecoration; import org.bukkit.Bukkit; diff --git a/src/main/java/fr/openmc/core/features/city/conditions/CityCreateConditions.java b/src/main/java/fr/openmc/core/features/city/conditions/CityCreateConditions.java index 83c613169..078804c4c 100644 --- a/src/main/java/fr/openmc/core/features/city/conditions/CityCreateConditions.java +++ b/src/main/java/fr/openmc/core/features/city/conditions/CityCreateConditions.java @@ -4,11 +4,11 @@ import fr.openmc.core.features.city.CityManager; import fr.openmc.core.features.economy.EconomyManager; import fr.openmc.core.registry.items.CustomItemRegistry; -import fr.openmc.core.utils.InputUtils; -import fr.openmc.core.utils.ItemUtils; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.bukkit.ItemUtils; +import fr.openmc.core.utils.text.InputUtils; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.TextDecoration; import org.bukkit.entity.Player; diff --git a/src/main/java/fr/openmc/core/features/city/conditions/CityInviteConditions.java b/src/main/java/fr/openmc/core/features/city/conditions/CityInviteConditions.java index bacc1f5a0..332dabac7 100644 --- a/src/main/java/fr/openmc/core/features/city/conditions/CityInviteConditions.java +++ b/src/main/java/fr/openmc/core/features/city/conditions/CityInviteConditions.java @@ -6,9 +6,9 @@ import fr.openmc.core.features.city.commands.CityInviteCommands; import fr.openmc.core.features.city.sub.milestone.rewards.MemberLimitRewards; import fr.openmc.core.features.settings.PlayerSettingsManager; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.entity.Player; diff --git a/src/main/java/fr/openmc/core/features/city/conditions/CityKickCondition.java b/src/main/java/fr/openmc/core/features/city/conditions/CityKickCondition.java index 636816823..7b7699d49 100644 --- a/src/main/java/fr/openmc/core/features/city/conditions/CityKickCondition.java +++ b/src/main/java/fr/openmc/core/features/city/conditions/CityKickCondition.java @@ -2,9 +2,9 @@ import fr.openmc.core.features.city.City; import fr.openmc.core.features.city.CityPermission; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import org.bukkit.OfflinePlayer; import org.bukkit.entity.Player; diff --git a/src/main/java/fr/openmc/core/features/city/conditions/CityLeaveCondition.java b/src/main/java/fr/openmc/core/features/city/conditions/CityLeaveCondition.java index 855493240..aecc943ae 100644 --- a/src/main/java/fr/openmc/core/features/city/conditions/CityLeaveCondition.java +++ b/src/main/java/fr/openmc/core/features/city/conditions/CityLeaveCondition.java @@ -2,9 +2,9 @@ import fr.openmc.core.features.city.City; import fr.openmc.core.features.city.CityPermission; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.entity.Player; diff --git a/src/main/java/fr/openmc/core/features/city/conditions/CityManageConditions.java b/src/main/java/fr/openmc/core/features/city/conditions/CityManageConditions.java index f0bfd506d..f7a463298 100644 --- a/src/main/java/fr/openmc/core/features/city/conditions/CityManageConditions.java +++ b/src/main/java/fr/openmc/core/features/city/conditions/CityManageConditions.java @@ -3,9 +3,9 @@ import fr.openmc.api.cooldown.DynamicCooldownManager; import fr.openmc.core.features.city.City; import fr.openmc.core.features.city.CityPermission; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.entity.Player; diff --git a/src/main/java/fr/openmc/core/features/city/conditions/CityPermsConditions.java b/src/main/java/fr/openmc/core/features/city/conditions/CityPermsConditions.java index fb4929c21..5735bda9f 100644 --- a/src/main/java/fr/openmc/core/features/city/conditions/CityPermsConditions.java +++ b/src/main/java/fr/openmc/core/features/city/conditions/CityPermsConditions.java @@ -3,9 +3,9 @@ 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.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import org.bukkit.entity.Player; import java.util.Objects; diff --git a/src/main/java/fr/openmc/core/features/city/conditions/CityTypeConditions.java b/src/main/java/fr/openmc/core/features/city/conditions/CityTypeConditions.java index 44dbdae71..f35c72bbe 100644 --- a/src/main/java/fr/openmc/core/features/city/conditions/CityTypeConditions.java +++ b/src/main/java/fr/openmc/core/features/city/conditions/CityTypeConditions.java @@ -5,10 +5,10 @@ import fr.openmc.core.features.city.CityPermission; import fr.openmc.core.features.city.CityType; import fr.openmc.core.features.economy.EconomyManager; -import fr.openmc.core.utils.DateUtils; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.DateUtils; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.entity.Player; diff --git a/src/main/java/fr/openmc/core/features/city/conditions/CityUnclaimCondition.java b/src/main/java/fr/openmc/core/features/city/conditions/CityUnclaimCondition.java index 7a609909d..b179343dd 100644 --- a/src/main/java/fr/openmc/core/features/city/conditions/CityUnclaimCondition.java +++ b/src/main/java/fr/openmc/core/features/city/conditions/CityUnclaimCondition.java @@ -2,9 +2,9 @@ import fr.openmc.core.features.city.City; import fr.openmc.core.features.city.CityPermission; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.Bukkit; import org.bukkit.entity.Player; diff --git a/src/main/java/fr/openmc/core/features/city/listeners/protections/ExplodeProtection.java b/src/main/java/fr/openmc/core/features/city/listeners/protections/ExplodeProtection.java index b39fb9d5c..7d7840bad 100644 --- a/src/main/java/fr/openmc/core/features/city/listeners/protections/ExplodeProtection.java +++ b/src/main/java/fr/openmc/core/features/city/listeners/protections/ExplodeProtection.java @@ -5,9 +5,9 @@ import fr.openmc.core.features.city.CityType; import fr.openmc.core.features.city.ProtectionsManager; import fr.openmc.core.utils.cache.CacheOfflinePlayer; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.OfflinePlayer; import org.bukkit.entity.Entity; diff --git a/src/main/java/fr/openmc/core/features/city/menu/CityChunkMenu.java b/src/main/java/fr/openmc/core/features/city/menu/CityChunkMenu.java index b444fdaa2..5bcf501c2 100644 --- a/src/main/java/fr/openmc/core/features/city/menu/CityChunkMenu.java +++ b/src/main/java/fr/openmc/core/features/city/menu/CityChunkMenu.java @@ -14,11 +14,11 @@ import fr.openmc.core.features.city.actions.CityCreateAction; import fr.openmc.core.features.city.actions.CityUnclaimAction; import fr.openmc.core.features.economy.EconomyManager; -import fr.openmc.core.utils.ChunkInfo; -import fr.openmc.core.utils.ChunkPos; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; +import fr.openmc.core.utils.world.chunk.ChunkInfo; +import fr.openmc.core.utils.world.chunk.ChunkPos; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.TextDecoration; import org.bukkit.Bukkit; diff --git a/src/main/java/fr/openmc/core/features/city/menu/CityModifyMenu.java b/src/main/java/fr/openmc/core/features/city/menu/CityModifyMenu.java index 0ddc0907c..66940adc0 100644 --- a/src/main/java/fr/openmc/core/features/city/menu/CityModifyMenu.java +++ b/src/main/java/fr/openmc/core/features/city/menu/CityModifyMenu.java @@ -1,7 +1,7 @@ package fr.openmc.core.features.city.menu; import fr.openmc.api.cooldown.DynamicCooldownManager; -import fr.openmc.api.input.DialogInput; +import fr.openmc.api.input.dialog.DialogInput; import fr.openmc.api.menulib.Menu; import fr.openmc.api.menulib.utils.InventorySize; import fr.openmc.api.menulib.utils.ItemBuilder; @@ -12,11 +12,11 @@ import fr.openmc.core.features.city.CityPermission; import fr.openmc.core.features.city.actions.CityDeleteAction; import fr.openmc.core.features.city.conditions.CityManageConditions; -import fr.openmc.core.utils.DateUtils; -import fr.openmc.core.utils.InputUtils; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.DateUtils; +import fr.openmc.core.utils.text.InputUtils; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -29,7 +29,7 @@ import java.util.Map; import java.util.function.Supplier; -import static fr.openmc.core.utils.InputUtils.MAX_LENGTH_CITY; +import static fr.openmc.core.utils.text.InputUtils.MAX_LENGTH_CITY; public class CityModifyMenu extends Menu { diff --git a/src/main/java/fr/openmc/core/features/city/menu/CityPermsMenu.java b/src/main/java/fr/openmc/core/features/city/menu/CityPermsMenu.java index 85c40b646..3b9351f61 100644 --- a/src/main/java/fr/openmc/core/features/city/menu/CityPermsMenu.java +++ b/src/main/java/fr/openmc/core/features/city/menu/CityPermsMenu.java @@ -11,9 +11,9 @@ import fr.openmc.core.features.city.commands.CityPermsCommands; import fr.openmc.core.registry.items.CustomItemRegistry; import fr.openmc.core.utils.cache.CacheOfflinePlayer; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.TextDecoration; import org.bukkit.Material; diff --git a/src/main/java/fr/openmc/core/features/city/menu/CityTopMenu.java b/src/main/java/fr/openmc/core/features/city/menu/CityTopMenu.java index 2a793806e..b89cd10d6 100644 --- a/src/main/java/fr/openmc/core/features/city/menu/CityTopMenu.java +++ b/src/main/java/fr/openmc/core/features/city/menu/CityTopMenu.java @@ -11,7 +11,7 @@ import fr.openmc.core.features.city.sub.milestone.rewards.MemberLimitRewards; import fr.openmc.core.features.economy.EconomyManager; import fr.openmc.core.features.leaderboards.LeaderboardManager; -import fr.openmc.core.utils.SkullUtils; +import fr.openmc.core.utils.bukkit.SkullUtils; import fr.openmc.core.utils.cache.PlayerNameCache; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; diff --git a/src/main/java/fr/openmc/core/features/city/menu/CityTransferMenu.java b/src/main/java/fr/openmc/core/features/city/menu/CityTransferMenu.java index b7d4af2bf..7bdb6a925 100644 --- a/src/main/java/fr/openmc/core/features/city/menu/CityTransferMenu.java +++ b/src/main/java/fr/openmc/core/features/city/menu/CityTransferMenu.java @@ -9,11 +9,11 @@ import fr.openmc.core.features.city.CityPermission; import fr.openmc.core.features.city.actions.CityTransferAction; import fr.openmc.core.registry.items.CustomItemRegistry; -import fr.openmc.core.utils.SkullUtils; +import fr.openmc.core.utils.bukkit.SkullUtils; import fr.openmc.core.utils.cache.CacheOfflinePlayer; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.TextDecoration; import org.bukkit.Material; diff --git a/src/main/java/fr/openmc/core/features/city/menu/NoCityMenu.java b/src/main/java/fr/openmc/core/features/city/menu/NoCityMenu.java index 8940f000a..3301d9f0d 100644 --- a/src/main/java/fr/openmc/core/features/city/menu/NoCityMenu.java +++ b/src/main/java/fr/openmc/core/features/city/menu/NoCityMenu.java @@ -1,7 +1,7 @@ package fr.openmc.core.features.city.menu; import fr.openmc.api.cooldown.DynamicCooldownManager; -import fr.openmc.api.input.DialogInput; +import fr.openmc.api.input.dialog.DialogInput; import fr.openmc.api.menulib.Menu; import fr.openmc.api.menulib.utils.InventorySize; import fr.openmc.api.menulib.utils.ItemBuilder; @@ -11,10 +11,10 @@ import fr.openmc.core.features.city.commands.CityInviteCommands; import fr.openmc.core.features.city.conditions.CityCreateConditions; import fr.openmc.core.features.economy.EconomyManager; -import fr.openmc.core.utils.DateUtils; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.DateUtils; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.TextDecoration; import org.bukkit.Material; @@ -29,7 +29,7 @@ import java.util.Map; import java.util.function.Supplier; -import static fr.openmc.core.utils.InputUtils.MAX_LENGTH_CITY; +import static fr.openmc.core.utils.text.InputUtils.MAX_LENGTH_CITY; public class NoCityMenu extends Menu { diff --git a/src/main/java/fr/openmc/core/features/city/menu/list/CityListDetailsMenu.java b/src/main/java/fr/openmc/core/features/city/menu/list/CityListDetailsMenu.java index d36f5b0d9..bf7dc1ea5 100644 --- a/src/main/java/fr/openmc/core/features/city/menu/list/CityListDetailsMenu.java +++ b/src/main/java/fr/openmc/core/features/city/menu/list/CityListDetailsMenu.java @@ -16,7 +16,7 @@ import fr.openmc.core.features.city.sub.milestone.rewards.FeaturesRewards; import fr.openmc.core.features.city.sub.milestone.rewards.MemberLimitRewards; import fr.openmc.core.features.economy.EconomyManager; -import fr.openmc.core.utils.SkullUtils; +import fr.openmc.core.utils.bukkit.SkullUtils; import fr.openmc.core.utils.cache.CacheOfflinePlayer; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.TextDecoration; diff --git a/src/main/java/fr/openmc/core/features/city/menu/list/CityListMenu.java b/src/main/java/fr/openmc/core/features/city/menu/list/CityListMenu.java index a905cf75b..9d43ee387 100644 --- a/src/main/java/fr/openmc/core/features/city/menu/list/CityListMenu.java +++ b/src/main/java/fr/openmc/core/features/city/menu/list/CityListMenu.java @@ -14,7 +14,7 @@ import fr.openmc.core.features.city.sub.milestone.rewards.FeaturesRewards; import fr.openmc.core.features.city.sub.milestone.rewards.MemberLimitRewards; import fr.openmc.core.features.economy.EconomyManager; -import fr.openmc.core.utils.SkullUtils; +import fr.openmc.core.utils.bukkit.SkullUtils; import fr.openmc.core.utils.cache.PlayerNameCache; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; diff --git a/src/main/java/fr/openmc/core/features/city/menu/list/CityPlayerListMenu.java b/src/main/java/fr/openmc/core/features/city/menu/list/CityPlayerListMenu.java index 3ada1024e..2c670166c 100644 --- a/src/main/java/fr/openmc/core/features/city/menu/list/CityPlayerListMenu.java +++ b/src/main/java/fr/openmc/core/features/city/menu/list/CityPlayerListMenu.java @@ -6,7 +6,7 @@ import fr.openmc.api.menulib.utils.StaticSlots; import fr.openmc.core.features.city.City; import fr.openmc.core.registry.items.CustomItemRegistry; -import fr.openmc.core.utils.SkullUtils; +import fr.openmc.core.utils.bukkit.SkullUtils; import fr.openmc.core.utils.cache.CacheOfflinePlayer; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.TextDecoration; diff --git a/src/main/java/fr/openmc/core/features/city/menu/main/buttons/BankButton.java b/src/main/java/fr/openmc/core/features/city/menu/main/buttons/BankButton.java index 176ce61cd..c9edaea00 100644 --- a/src/main/java/fr/openmc/core/features/city/menu/main/buttons/BankButton.java +++ b/src/main/java/fr/openmc/core/features/city/menu/main/buttons/BankButton.java @@ -8,9 +8,9 @@ import fr.openmc.core.features.city.sub.bank.conditions.CityBankConditions; import fr.openmc.core.features.city.sub.bank.menu.CityBankMenu; import fr.openmc.core.features.city.sub.milestone.rewards.FeaturesRewards; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.Material; import org.bukkit.NamespacedKey; diff --git a/src/main/java/fr/openmc/core/features/city/menu/main/buttons/ManageButton.java b/src/main/java/fr/openmc/core/features/city/menu/main/buttons/ManageButton.java index 92edc2419..97fc4f88a 100644 --- a/src/main/java/fr/openmc/core/features/city/menu/main/buttons/ManageButton.java +++ b/src/main/java/fr/openmc/core/features/city/menu/main/buttons/ManageButton.java @@ -8,9 +8,9 @@ import fr.openmc.core.features.city.menu.CityModifyMenu; import fr.openmc.core.features.city.sub.milestone.rewards.MemberLimitRewards; import fr.openmc.core.utils.cache.CacheOfflinePlayer; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.TextDecoration; diff --git a/src/main/java/fr/openmc/core/features/city/menu/main/buttons/MapButton.java b/src/main/java/fr/openmc/core/features/city/menu/main/buttons/MapButton.java index 31f031759..45e5476b6 100644 --- a/src/main/java/fr/openmc/core/features/city/menu/main/buttons/MapButton.java +++ b/src/main/java/fr/openmc/core/features/city/menu/main/buttons/MapButton.java @@ -6,9 +6,9 @@ import fr.openmc.core.features.city.City; import fr.openmc.core.features.city.CityPermission; import fr.openmc.core.features.city.menu.CityChunkMenu; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.Material; import org.bukkit.NamespacedKey; diff --git a/src/main/java/fr/openmc/core/features/city/menu/main/buttons/MascotsButton.java b/src/main/java/fr/openmc/core/features/city/menu/main/buttons/MascotsButton.java index 17e914db1..c13d69941 100644 --- a/src/main/java/fr/openmc/core/features/city/menu/main/buttons/MascotsButton.java +++ b/src/main/java/fr/openmc/core/features/city/menu/main/buttons/MascotsButton.java @@ -9,7 +9,7 @@ import fr.openmc.core.features.city.sub.mascots.menu.MascotMenu; import fr.openmc.core.features.city.sub.mascots.menu.MascotsDeadMenu; import fr.openmc.core.features.city.sub.mascots.models.Mascot; -import fr.openmc.core.utils.DateUtils; +import fr.openmc.core.utils.text.DateUtils; import net.kyori.adventure.text.Component; import org.bukkit.Material; import org.bukkit.NamespacedKey; diff --git a/src/main/java/fr/openmc/core/features/city/menu/main/buttons/MayorButton.java b/src/main/java/fr/openmc/core/features/city/menu/main/buttons/MayorButton.java index f2564aa97..3747ac5bc 100644 --- a/src/main/java/fr/openmc/core/features/city/menu/main/buttons/MayorButton.java +++ b/src/main/java/fr/openmc/core/features/city/menu/main/buttons/MayorButton.java @@ -10,7 +10,7 @@ import fr.openmc.core.features.city.sub.mayor.actions.MayorCommandAction; import fr.openmc.core.features.city.sub.mayor.managers.MayorManager; import fr.openmc.core.features.city.sub.milestone.rewards.FeaturesRewards; -import fr.openmc.core.utils.DateUtils; +import fr.openmc.core.utils.text.DateUtils; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.TextDecoration; diff --git a/src/main/java/fr/openmc/core/features/city/menu/main/buttons/MilestoneButton.java b/src/main/java/fr/openmc/core/features/city/menu/main/buttons/MilestoneButton.java index 8c4d579e6..512e3f0cf 100644 --- a/src/main/java/fr/openmc/core/features/city/menu/main/buttons/MilestoneButton.java +++ b/src/main/java/fr/openmc/core/features/city/menu/main/buttons/MilestoneButton.java @@ -6,9 +6,9 @@ import fr.openmc.core.features.city.City; import fr.openmc.core.features.city.CityManager; import fr.openmc.core.features.city.sub.milestone.menu.CityMilestoneMenu; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.Material; import org.bukkit.NamespacedKey; diff --git a/src/main/java/fr/openmc/core/features/city/menu/main/buttons/NotationsButton.java b/src/main/java/fr/openmc/core/features/city/menu/main/buttons/NotationsButton.java index 6b21fa273..f4e72a39d 100644 --- a/src/main/java/fr/openmc/core/features/city/menu/main/buttons/NotationsButton.java +++ b/src/main/java/fr/openmc/core/features/city/menu/main/buttons/NotationsButton.java @@ -9,7 +9,7 @@ import fr.openmc.core.features.city.sub.notation.menu.NotationDialog; import fr.openmc.core.features.city.sub.notation.models.CityNotation; import fr.openmc.core.features.economy.EconomyManager; -import fr.openmc.core.utils.DateUtils; +import fr.openmc.core.utils.text.DateUtils; import net.kyori.adventure.text.Component; import org.bukkit.Material; import org.bukkit.NamespacedKey; diff --git a/src/main/java/fr/openmc/core/features/city/menu/main/buttons/RankButton.java b/src/main/java/fr/openmc/core/features/city/menu/main/buttons/RankButton.java index 976b8f390..acb7e9c48 100644 --- a/src/main/java/fr/openmc/core/features/city/menu/main/buttons/RankButton.java +++ b/src/main/java/fr/openmc/core/features/city/menu/main/buttons/RankButton.java @@ -6,9 +6,9 @@ import fr.openmc.core.features.city.City; import fr.openmc.core.features.city.sub.milestone.rewards.FeaturesRewards; import fr.openmc.core.features.city.sub.rank.menus.CityRanksMenu; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.Material; import org.bukkit.NamespacedKey; diff --git a/src/main/java/fr/openmc/core/features/city/menu/main/buttons/TypeButton.java b/src/main/java/fr/openmc/core/features/city/menu/main/buttons/TypeButton.java index eaffc048a..588c2e187 100644 --- a/src/main/java/fr/openmc/core/features/city/menu/main/buttons/TypeButton.java +++ b/src/main/java/fr/openmc/core/features/city/menu/main/buttons/TypeButton.java @@ -9,7 +9,7 @@ import fr.openmc.core.features.city.CityPermission; import fr.openmc.core.features.city.CityType; import fr.openmc.core.features.city.menu.CityTypeMenu; -import fr.openmc.core.utils.DateUtils; +import fr.openmc.core.utils.text.DateUtils; import net.kyori.adventure.text.Component; import org.bukkit.Material; import org.bukkit.NamespacedKey; diff --git a/src/main/java/fr/openmc/core/features/city/menu/playerlist/CityPlayerGestionMenu.java b/src/main/java/fr/openmc/core/features/city/menu/playerlist/CityPlayerGestionMenu.java index a4d93af17..37d1ae687 100644 --- a/src/main/java/fr/openmc/core/features/city/menu/playerlist/CityPlayerGestionMenu.java +++ b/src/main/java/fr/openmc/core/features/city/menu/playerlist/CityPlayerGestionMenu.java @@ -10,8 +10,8 @@ import fr.openmc.core.features.city.actions.CityKickAction; import fr.openmc.core.features.city.conditions.CityKickCondition; import fr.openmc.core.features.city.menu.CityPermsMenu; -import fr.openmc.core.utils.SkullUtils; -import fr.openmc.core.utils.messages.MessagesManager; +import fr.openmc.core.utils.bukkit.SkullUtils; +import fr.openmc.core.utils.text.messages.MessagesManager; import net.kyori.adventure.text.Component; import org.bukkit.Material; import org.bukkit.OfflinePlayer; diff --git a/src/main/java/fr/openmc/core/features/city/menu/playerlist/CityPlayerListMenu.java b/src/main/java/fr/openmc/core/features/city/menu/playerlist/CityPlayerListMenu.java index fb532262c..2e1585079 100644 --- a/src/main/java/fr/openmc/core/features/city/menu/playerlist/CityPlayerListMenu.java +++ b/src/main/java/fr/openmc/core/features/city/menu/playerlist/CityPlayerListMenu.java @@ -1,6 +1,6 @@ package fr.openmc.core.features.city.menu.playerlist; -import fr.openmc.api.input.DialogInput; +import fr.openmc.api.input.dialog.DialogInput; import fr.openmc.api.menulib.PaginatedMenu; import fr.openmc.api.menulib.template.ConfirmMenu; import fr.openmc.api.menulib.utils.InventorySize; @@ -14,12 +14,12 @@ import fr.openmc.core.features.city.menu.CityPermsMenu; import fr.openmc.core.features.city.sub.milestone.rewards.MemberLimitRewards; import fr.openmc.core.registry.items.CustomItemRegistry; -import fr.openmc.core.utils.InputUtils; -import fr.openmc.core.utils.SkullUtils; +import fr.openmc.core.utils.bukkit.SkullUtils; import fr.openmc.core.utils.cache.CacheOfflinePlayer; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.InputUtils; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.TextDecoration; import org.bukkit.Bukkit; @@ -34,7 +34,7 @@ import java.util.*; -import static fr.openmc.core.utils.InputUtils.MAX_LENGTH_PLAYERNAME; +import static fr.openmc.core.utils.text.InputUtils.MAX_LENGTH_PLAYERNAME; public class CityPlayerListMenu extends PaginatedMenu { diff --git a/src/main/java/fr/openmc/core/features/city/models/DBCityChest.java b/src/main/java/fr/openmc/core/features/city/models/DBCityChest.java index 9763634c7..faaeb7779 100644 --- a/src/main/java/fr/openmc/core/features/city/models/DBCityChest.java +++ b/src/main/java/fr/openmc/core/features/city/models/DBCityChest.java @@ -3,7 +3,7 @@ import com.j256.ormlite.field.DataType; import com.j256.ormlite.field.DatabaseField; import com.j256.ormlite.table.DatabaseTable; -import fr.openmc.core.utils.serializer.BukkitSerializer; +import fr.openmc.core.utils.bukkit.serializer.BukkitSerializer; import lombok.Getter; import org.bukkit.inventory.ItemStack; diff --git a/src/main/java/fr/openmc/core/features/city/models/DBCityClaim.java b/src/main/java/fr/openmc/core/features/city/models/DBCityClaim.java index 8c203ab2f..3b0870e95 100644 --- a/src/main/java/fr/openmc/core/features/city/models/DBCityClaim.java +++ b/src/main/java/fr/openmc/core/features/city/models/DBCityClaim.java @@ -2,7 +2,7 @@ import com.j256.ormlite.field.DatabaseField; import com.j256.ormlite.table.DatabaseTable; -import fr.openmc.core.utils.ChunkPos; +import fr.openmc.core.utils.world.chunk.ChunkPos; import lombok.Getter; import java.util.UUID; diff --git a/src/main/java/fr/openmc/core/features/city/models/DBCityRank.java b/src/main/java/fr/openmc/core/features/city/models/DBCityRank.java index a77ecca71..d20711d3e 100644 --- a/src/main/java/fr/openmc/core/features/city/models/DBCityRank.java +++ b/src/main/java/fr/openmc/core/features/city/models/DBCityRank.java @@ -3,9 +3,9 @@ import com.j256.ormlite.field.DatabaseField; import com.j256.ormlite.table.DatabaseTable; import fr.openmc.core.features.city.CityPermission; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import lombok.Getter; import net.kyori.adventure.text.Component; import org.bukkit.Material; diff --git a/src/main/java/fr/openmc/core/features/city/sub/bank/CityBankManager.java b/src/main/java/fr/openmc/core/features/city/sub/bank/CityBankManager.java index 4da8ccfe5..739a1704f 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/bank/CityBankManager.java +++ b/src/main/java/fr/openmc/core/features/city/sub/bank/CityBankManager.java @@ -10,10 +10,10 @@ import fr.openmc.core.features.city.sub.mayor.perks.Perks; import fr.openmc.core.features.city.sub.milestone.rewards.InterestRewards; import fr.openmc.core.features.economy.EconomyManager; -import fr.openmc.core.utils.InputUtils; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.InputUtils; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.entity.Player; diff --git a/src/main/java/fr/openmc/core/features/city/sub/bank/conditions/CityBankConditions.java b/src/main/java/fr/openmc/core/features/city/sub/bank/conditions/CityBankConditions.java index f850d25fd..d385cb517 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/bank/conditions/CityBankConditions.java +++ b/src/main/java/fr/openmc/core/features/city/sub/bank/conditions/CityBankConditions.java @@ -4,9 +4,9 @@ import fr.openmc.core.features.city.CityPermission; import fr.openmc.core.features.city.CityType; import fr.openmc.core.features.city.sub.milestone.rewards.FeaturesRewards; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.entity.Player; diff --git a/src/main/java/fr/openmc/core/features/city/sub/bank/menu/CityBankDepositMenu.java b/src/main/java/fr/openmc/core/features/city/sub/bank/menu/CityBankDepositMenu.java index ee6405401..9fcc2468a 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/bank/menu/CityBankDepositMenu.java +++ b/src/main/java/fr/openmc/core/features/city/sub/bank/menu/CityBankDepositMenu.java @@ -1,6 +1,6 @@ package fr.openmc.core.features.city.sub.bank.menu; -import fr.openmc.api.input.DialogInput; +import fr.openmc.api.input.dialog.DialogInput; import fr.openmc.api.menulib.Menu; import fr.openmc.api.menulib.utils.InventorySize; import fr.openmc.api.menulib.utils.ItemBuilder; @@ -9,7 +9,7 @@ import fr.openmc.core.features.city.CityPermission; import fr.openmc.core.features.city.sub.bank.conditions.CityBankConditions; import fr.openmc.core.features.economy.EconomyManager; -import fr.openmc.core.utils.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.MessagesManager; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.TextDecoration; import org.bukkit.Material; @@ -23,7 +23,7 @@ import java.util.List; import java.util.Map; -import static fr.openmc.core.utils.InputUtils.MAX_LENGTH; +import static fr.openmc.core.utils.text.InputUtils.MAX_LENGTH; public class CityBankDepositMenu extends Menu { diff --git a/src/main/java/fr/openmc/core/features/city/sub/bank/menu/CityBankMenu.java b/src/main/java/fr/openmc/core/features/city/sub/bank/menu/CityBankMenu.java index e05fe8025..9644d0828 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/bank/menu/CityBankMenu.java +++ b/src/main/java/fr/openmc/core/features/city/sub/bank/menu/CityBankMenu.java @@ -10,10 +10,10 @@ import fr.openmc.core.features.city.CityPermission; import fr.openmc.core.features.economy.BankManager; import fr.openmc.core.features.economy.EconomyManager; -import fr.openmc.core.utils.DateUtils; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.DateUtils; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.TextDecoration; import org.bukkit.Material; diff --git a/src/main/java/fr/openmc/core/features/city/sub/bank/menu/CityBankWithdrawMenu.java b/src/main/java/fr/openmc/core/features/city/sub/bank/menu/CityBankWithdrawMenu.java index 4b7202cfb..e20225580 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/bank/menu/CityBankWithdrawMenu.java +++ b/src/main/java/fr/openmc/core/features/city/sub/bank/menu/CityBankWithdrawMenu.java @@ -1,6 +1,6 @@ package fr.openmc.core.features.city.sub.bank.menu; -import fr.openmc.api.input.DialogInput; +import fr.openmc.api.input.dialog.DialogInput; import fr.openmc.api.menulib.Menu; import fr.openmc.api.menulib.utils.InventorySize; import fr.openmc.api.menulib.utils.ItemBuilder; @@ -9,7 +9,7 @@ import fr.openmc.core.features.city.CityPermission; import fr.openmc.core.features.city.sub.bank.conditions.CityBankConditions; import fr.openmc.core.features.economy.EconomyManager; -import fr.openmc.core.utils.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.MessagesManager; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.TextDecoration; import org.bukkit.Material; @@ -23,7 +23,7 @@ import java.util.List; import java.util.Map; -import static fr.openmc.core.utils.InputUtils.MAX_LENGTH; +import static fr.openmc.core.utils.text.InputUtils.MAX_LENGTH; public class CityBankWithdrawMenu extends Menu { diff --git a/src/main/java/fr/openmc/core/features/city/sub/mascots/MascotsManager.java b/src/main/java/fr/openmc/core/features/city/sub/mascots/MascotsManager.java index 4f20f0405..a9b50b77e 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/mascots/MascotsManager.java +++ b/src/main/java/fr/openmc/core/features/city/sub/mascots/MascotsManager.java @@ -7,6 +7,8 @@ import fr.openmc.api.cooldown.DynamicCooldownManager; import fr.openmc.core.CommandsManager; import fr.openmc.core.OMCPlugin; +import fr.openmc.core.bootstrap.features.Feature; +import fr.openmc.core.bootstrap.features.types.DatabaseFeature; import fr.openmc.core.features.city.City; import fr.openmc.core.features.city.CityManager; import fr.openmc.core.features.city.sub.mascots.commands.AdminMascotsCommands; @@ -15,10 +17,10 @@ import fr.openmc.core.features.city.sub.mascots.models.MascotsLevels; import fr.openmc.core.features.city.sub.mascots.utils.MascotRegenerationUtils; import fr.openmc.core.features.city.sub.mascots.utils.MascotUtils; -import fr.openmc.core.utils.ItemUtils; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.bukkit.ItemUtils; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.*; import org.bukkit.attribute.Attribute; @@ -40,7 +42,7 @@ import java.util.List; import java.util.UUID; -public class MascotsManager { +public class MascotsManager extends Feature implements DatabaseFeature { public static final List movingMascots = new ArrayList<>(); public static final HashMap mascotsByCityUUID = new HashMap<>(); public static final HashMap mascotsByEntityUUID = new HashMap<>(); @@ -49,7 +51,8 @@ public class MascotsManager { public static NamespacedKey mascotsKey; private static Dao mascotsDao; - public static void init() { + @Override + public void init() { // changement du spigot.yml pour permettre aux mascottes d'avoir 3000 cœurs File spigotYML = new File("spigot.yml"); YamlConfiguration spigotYMLConfig = YamlConfiguration.loadConfiguration(spigotYML); @@ -90,7 +93,13 @@ public static void init() { } } - public static void initDB(ConnectionSource connectionSource) throws SQLException { + @Override + public void save() { + MascotsManager.saveMascots(); + } + + @Override + public void initDB(ConnectionSource connectionSource) throws SQLException { TableUtils.createTableIfNotExists(connectionSource, Mascot.class); mascotsDao = DaoManager.createDao(connectionSource, Mascot.class); } diff --git a/src/main/java/fr/openmc/core/features/city/sub/mascots/commands/AdminMascotsCommands.java b/src/main/java/fr/openmc/core/features/city/sub/mascots/commands/AdminMascotsCommands.java index b08ddd69b..2a8f61c15 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/mascots/commands/AdminMascotsCommands.java +++ b/src/main/java/fr/openmc/core/features/city/sub/mascots/commands/AdminMascotsCommands.java @@ -4,9 +4,9 @@ import fr.openmc.core.features.city.CityManager; import fr.openmc.core.features.city.commands.autocomplete.CityNameAutoComplete; import fr.openmc.core.features.city.sub.mascots.MascotsManager; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.entity.Player; import revxrsal.commands.annotation.Command; diff --git a/src/main/java/fr/openmc/core/features/city/sub/mascots/listeners/MascotsDamageListener.java b/src/main/java/fr/openmc/core/features/city/sub/mascots/listeners/MascotsDamageListener.java index 6c1656675..04bc7d3cc 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/mascots/listeners/MascotsDamageListener.java +++ b/src/main/java/fr/openmc/core/features/city/sub/mascots/listeners/MascotsDamageListener.java @@ -12,9 +12,9 @@ import fr.openmc.core.features.city.sub.mayor.perks.Perks; import fr.openmc.core.features.city.sub.mayor.perks.basic.IronBloodPerk; import fr.openmc.core.features.city.sub.war.War; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; diff --git a/src/main/java/fr/openmc/core/features/city/sub/mascots/listeners/MascotsInteractionListener.java b/src/main/java/fr/openmc/core/features/city/sub/mascots/listeners/MascotsInteractionListener.java index 6d508d79c..e594ee915 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/mascots/listeners/MascotsInteractionListener.java +++ b/src/main/java/fr/openmc/core/features/city/sub/mascots/listeners/MascotsInteractionListener.java @@ -7,9 +7,9 @@ import fr.openmc.core.features.city.sub.mascots.menu.MascotsDeadMenu; import fr.openmc.core.features.city.sub.mascots.models.Mascot; import fr.openmc.core.features.city.sub.mascots.utils.MascotUtils; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import lombok.SneakyThrows; import net.kyori.adventure.text.Component; import org.bukkit.entity.Entity; diff --git a/src/main/java/fr/openmc/core/features/city/sub/mascots/listeners/MascotsRenameListener.java b/src/main/java/fr/openmc/core/features/city/sub/mascots/listeners/MascotsRenameListener.java index b1f5fe94e..568e52eb5 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/mascots/listeners/MascotsRenameListener.java +++ b/src/main/java/fr/openmc/core/features/city/sub/mascots/listeners/MascotsRenameListener.java @@ -5,9 +5,9 @@ import fr.openmc.core.features.city.sub.mascots.MascotsManager; import fr.openmc.core.features.city.sub.mascots.models.Mascot; import fr.openmc.core.features.city.sub.mascots.utils.MascotUtils; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.Material; import org.bukkit.entity.Entity; diff --git a/src/main/java/fr/openmc/core/features/city/sub/mascots/menu/MascotMenu.java b/src/main/java/fr/openmc/core/features/city/sub/mascots/menu/MascotMenu.java index 7bfb5c21f..7e28ca9d1 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/mascots/menu/MascotMenu.java +++ b/src/main/java/fr/openmc/core/features/city/sub/mascots/menu/MascotMenu.java @@ -14,11 +14,11 @@ import fr.openmc.core.features.city.sub.mascots.models.MascotsLevels; import fr.openmc.core.features.city.sub.milestone.rewards.MascotsLevelsRewards; import fr.openmc.core.registry.items.CustomItemRegistry; -import fr.openmc.core.utils.DateUtils; -import fr.openmc.core.utils.ItemUtils; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.bukkit.ItemUtils; +import fr.openmc.core.utils.text.DateUtils; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import io.papermc.paper.datacomponent.DataComponentTypes; import net.kyori.adventure.key.Key; import net.kyori.adventure.text.Component; diff --git a/src/main/java/fr/openmc/core/features/city/sub/mascots/menu/MascotsDeadMenu.java b/src/main/java/fr/openmc/core/features/city/sub/mascots/menu/MascotsDeadMenu.java index 09e60d256..a1fd661fa 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/mascots/menu/MascotsDeadMenu.java +++ b/src/main/java/fr/openmc/core/features/city/sub/mascots/menu/MascotsDeadMenu.java @@ -8,11 +8,11 @@ import fr.openmc.core.OMCPlugin; import fr.openmc.core.features.city.City; import fr.openmc.core.features.city.CityManager; -import fr.openmc.core.utils.DateUtils; -import fr.openmc.core.utils.ItemUtils; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.bukkit.ItemUtils; +import fr.openmc.core.utils.text.DateUtils; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/src/main/java/fr/openmc/core/features/city/sub/mascots/menu/MascotsSkinMenu.java b/src/main/java/fr/openmc/core/features/city/sub/mascots/menu/MascotsSkinMenu.java index 94771257e..ac4ac192f 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/mascots/menu/MascotsSkinMenu.java +++ b/src/main/java/fr/openmc/core/features/city/sub/mascots/menu/MascotsSkinMenu.java @@ -9,10 +9,10 @@ import fr.openmc.core.features.city.sub.mascots.models.MascotType; import fr.openmc.core.features.city.sub.milestone.rewards.MascotsSkinUnlockRewards; import fr.openmc.core.registry.items.CustomItemRegistry; -import fr.openmc.core.utils.ItemUtils; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.bukkit.ItemUtils; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.Material; import org.bukkit.Sound; diff --git a/src/main/java/fr/openmc/core/features/city/sub/mascots/models/MascotType.java b/src/main/java/fr/openmc/core/features/city/sub/mascots/models/MascotType.java index a6c19e6ae..89806c611 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/mascots/models/MascotType.java +++ b/src/main/java/fr/openmc/core/features/city/sub/mascots/models/MascotType.java @@ -1,7 +1,7 @@ package fr.openmc.core.features.city.sub.mascots.models; -import fr.openmc.core.utils.EntityUtils; import fr.openmc.core.utils.EnumUtils; +import fr.openmc.core.utils.world.EntityUtils; import lombok.Getter; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; diff --git a/src/main/java/fr/openmc/core/features/city/sub/mayor/actions/MayorCommandAction.java b/src/main/java/fr/openmc/core/features/city/sub/mayor/actions/MayorCommandAction.java index b7339f1e9..32136a619 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/mayor/actions/MayorCommandAction.java +++ b/src/main/java/fr/openmc/core/features/city/sub/mayor/actions/MayorCommandAction.java @@ -12,9 +12,9 @@ import fr.openmc.core.features.city.sub.mayor.menu.create.MayorCreateMenu; import fr.openmc.core.features.city.sub.mayor.menu.create.MenuType; import fr.openmc.core.features.city.sub.milestone.rewards.FeaturesRewards; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.Bukkit; import org.bukkit.entity.Player; diff --git a/src/main/java/fr/openmc/core/features/city/sub/mayor/actions/MayorSetWarpAction.java b/src/main/java/fr/openmc/core/features/city/sub/mayor/actions/MayorSetWarpAction.java index 6bdafa802..ac9460708 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/mayor/actions/MayorSetWarpAction.java +++ b/src/main/java/fr/openmc/core/features/city/sub/mayor/actions/MayorSetWarpAction.java @@ -8,9 +8,9 @@ import fr.openmc.core.features.city.sub.mayor.models.CityLaw; import fr.openmc.core.features.city.sub.mayor.models.Mayor; import fr.openmc.core.registry.items.CustomItemRegistry; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.Chunk; import org.bukkit.entity.Player; diff --git a/src/main/java/fr/openmc/core/features/city/sub/mayor/commands/AdminMayorCommands.java b/src/main/java/fr/openmc/core/features/city/sub/mayor/commands/AdminMayorCommands.java index 06282d999..79e33eb6b 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/mayor/commands/AdminMayorCommands.java +++ b/src/main/java/fr/openmc/core/features/city/sub/mayor/commands/AdminMayorCommands.java @@ -5,9 +5,9 @@ import fr.openmc.core.features.city.commands.autocomplete.CityNameAutoComplete; import fr.openmc.core.features.city.sub.mayor.ElectionType; import fr.openmc.core.features.city.sub.mayor.managers.MayorManager; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.entity.Player; import revxrsal.commands.annotation.*; diff --git a/src/main/java/fr/openmc/core/features/city/sub/mayor/commands/MayorCommands.java b/src/main/java/fr/openmc/core/features/city/sub/mayor/commands/MayorCommands.java index 9aee67364..36cb3c410 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/mayor/commands/MayorCommands.java +++ b/src/main/java/fr/openmc/core/features/city/sub/mayor/commands/MayorCommands.java @@ -6,10 +6,10 @@ import fr.openmc.core.features.city.sub.mayor.actions.MayorSetWarpAction; import fr.openmc.core.features.city.sub.mayor.managers.MayorManager; import fr.openmc.core.features.city.sub.mayor.models.CityLaw; -import fr.openmc.core.utils.PlayerUtils; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.bukkit.PlayerUtils; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.Location; import org.bukkit.entity.Player; diff --git a/src/main/java/fr/openmc/core/features/city/sub/mayor/listeners/PhaseListener.java b/src/main/java/fr/openmc/core/features/city/sub/mayor/listeners/PhaseListener.java index 1095f0237..a98fe2729 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/mayor/listeners/PhaseListener.java +++ b/src/main/java/fr/openmc/core/features/city/sub/mayor/listeners/PhaseListener.java @@ -2,7 +2,7 @@ import fr.openmc.core.OMCPlugin; import fr.openmc.core.features.city.sub.mayor.managers.MayorManager; -import fr.openmc.core.utils.DateUtils; +import fr.openmc.core.utils.text.DateUtils; import org.bukkit.scheduler.BukkitRunnable; import static fr.openmc.core.features.city.sub.mayor.managers.MayorManager.PHASE_1_DAY; diff --git a/src/main/java/fr/openmc/core/features/city/sub/mayor/listeners/UrneListener.java b/src/main/java/fr/openmc/core/features/city/sub/mayor/listeners/UrneListener.java index f646da5dc..7e5d192d4 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/mayor/listeners/UrneListener.java +++ b/src/main/java/fr/openmc/core/features/city/sub/mayor/listeners/UrneListener.java @@ -13,10 +13,10 @@ import fr.openmc.core.features.city.sub.mayor.managers.NPCManager; import fr.openmc.core.features.city.sub.mayor.menu.MayorVoteMenu; import fr.openmc.core.features.city.sub.milestone.rewards.FeaturesRewards; -import fr.openmc.core.utils.LocationUtils; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; +import fr.openmc.core.utils.world.LocationUtils; import net.kyori.adventure.text.Component; import org.bukkit.Chunk; import org.bukkit.GameMode; diff --git a/src/main/java/fr/openmc/core/features/city/sub/mayor/managers/NPCManager.java b/src/main/java/fr/openmc/core/features/city/sub/mayor/managers/NPCManager.java index 4821a70f0..3fb53298c 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/mayor/managers/NPCManager.java +++ b/src/main/java/fr/openmc/core/features/city/sub/mayor/managers/NPCManager.java @@ -19,9 +19,9 @@ import fr.openmc.core.features.city.sub.milestone.rewards.FeaturesRewards; import fr.openmc.core.registry.items.CustomItemRegistry; import fr.openmc.core.utils.cache.CacheOfflinePlayer; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.event.ClickEvent; import net.kyori.adventure.text.event.HoverEvent; diff --git a/src/main/java/fr/openmc/core/features/city/sub/mayor/menu/MayorElectionMenu.java b/src/main/java/fr/openmc/core/features/city/sub/mayor/menu/MayorElectionMenu.java index 545ec3e72..876588799 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/mayor/menu/MayorElectionMenu.java +++ b/src/main/java/fr/openmc/core/features/city/sub/mayor/menu/MayorElectionMenu.java @@ -4,7 +4,6 @@ import fr.openmc.api.menulib.Menu; import fr.openmc.api.menulib.utils.InventorySize; import fr.openmc.api.menulib.utils.ItemBuilder; -import fr.openmc.api.menulib.utils.ItemUtils; import fr.openmc.api.menulib.utils.MenuUtils; import fr.openmc.core.OMCPlugin; import fr.openmc.core.features.city.City; @@ -16,11 +15,11 @@ import fr.openmc.core.features.city.sub.mayor.menu.create.MayorModifyMenu; import fr.openmc.core.features.city.sub.mayor.menu.create.MenuType; import fr.openmc.core.features.city.sub.mayor.perks.Perks; -import fr.openmc.core.utils.DateUtils; -import fr.openmc.core.utils.SkullUtils; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.bukkit.SkullUtils; +import fr.openmc.core.utils.text.DateUtils; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.TextDecoration; import org.bukkit.Bukkit; diff --git a/src/main/java/fr/openmc/core/features/city/sub/mayor/menu/MayorLawMenu.java b/src/main/java/fr/openmc/core/features/city/sub/mayor/menu/MayorLawMenu.java index 5e016b565..2e542a2b0 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/mayor/menu/MayorLawMenu.java +++ b/src/main/java/fr/openmc/core/features/city/sub/mayor/menu/MayorLawMenu.java @@ -21,10 +21,10 @@ import fr.openmc.core.features.dream.DreamManager; import fr.openmc.core.features.dream.DreamUtils; import fr.openmc.core.features.dream.models.db.DBDreamPlayer; -import fr.openmc.core.utils.DateUtils; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.DateUtils; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.Bukkit; import org.bukkit.Location; diff --git a/src/main/java/fr/openmc/core/features/city/sub/mayor/menu/MayorMandateMenu.java b/src/main/java/fr/openmc/core/features/city/sub/mayor/menu/MayorMandateMenu.java index b9f4f136c..cb6e7ff2f 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/mayor/menu/MayorMandateMenu.java +++ b/src/main/java/fr/openmc/core/features/city/sub/mayor/menu/MayorMandateMenu.java @@ -4,15 +4,14 @@ import fr.openmc.api.menulib.Menu; import fr.openmc.api.menulib.utils.InventorySize; import fr.openmc.api.menulib.utils.ItemBuilder; -import fr.openmc.api.menulib.utils.ItemUtils; import fr.openmc.core.features.city.City; import fr.openmc.core.features.city.CityManager; import fr.openmc.core.features.city.CityPermission; import fr.openmc.core.features.city.sub.mayor.managers.PerkManager; import fr.openmc.core.features.city.sub.mayor.models.Mayor; import fr.openmc.core.features.city.sub.mayor.perks.Perks; +import fr.openmc.core.utils.bukkit.SkullUtils; import fr.openmc.core.utils.cache.CacheOfflinePlayer; -import fr.openmc.core.utils.SkullUtils; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.TextDecoration; import org.bukkit.Material; diff --git a/src/main/java/fr/openmc/core/features/city/sub/mayor/menu/MayorVoteMenu.java b/src/main/java/fr/openmc/core/features/city/sub/mayor/menu/MayorVoteMenu.java index f1e90b5d4..5893e75a4 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/mayor/menu/MayorVoteMenu.java +++ b/src/main/java/fr/openmc/core/features/city/sub/mayor/menu/MayorVoteMenu.java @@ -12,11 +12,11 @@ import fr.openmc.core.features.city.sub.mayor.models.MayorCandidate; import fr.openmc.core.features.city.sub.mayor.perks.Perks; import fr.openmc.core.registry.items.CustomItemRegistry; -import fr.openmc.core.utils.ColorUtils; -import fr.openmc.core.utils.SkullUtils; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.bukkit.SkullUtils; +import fr.openmc.core.utils.text.ColorUtils; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.TextDecoration; diff --git a/src/main/java/fr/openmc/core/features/city/sub/mayor/menu/create/MayorColorMenu.java b/src/main/java/fr/openmc/core/features/city/sub/mayor/menu/create/MayorColorMenu.java index 18487ec2c..af1d0b7f0 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/mayor/menu/create/MayorColorMenu.java +++ b/src/main/java/fr/openmc/core/features/city/sub/mayor/menu/create/MayorColorMenu.java @@ -11,11 +11,11 @@ import fr.openmc.core.features.city.sub.mayor.managers.MayorManager; import fr.openmc.core.features.city.sub.mayor.models.MayorCandidate; import fr.openmc.core.features.city.sub.mayor.perks.Perks; -import fr.openmc.core.utils.ColorUtils; import fr.openmc.core.utils.cache.CacheOfflinePlayer; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.ColorUtils; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.TextDecoration; diff --git a/src/main/java/fr/openmc/core/features/city/sub/mayor/menu/create/MayorCreateMenu.java b/src/main/java/fr/openmc/core/features/city/sub/mayor/menu/create/MayorCreateMenu.java index 9ffb7b680..3d7765311 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/mayor/menu/create/MayorCreateMenu.java +++ b/src/main/java/fr/openmc/core/features/city/sub/mayor/menu/create/MayorCreateMenu.java @@ -10,9 +10,9 @@ import fr.openmc.core.features.city.sub.mayor.menu.MayorElectionMenu; import fr.openmc.core.features.city.sub.mayor.perks.Perks; import fr.openmc.core.registry.items.CustomItemRegistry; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/src/main/java/fr/openmc/core/features/city/sub/mayor/menu/create/MayorModifyMenu.java b/src/main/java/fr/openmc/core/features/city/sub/mayor/menu/create/MayorModifyMenu.java index 9d27c7847..44c81491f 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/mayor/menu/create/MayorModifyMenu.java +++ b/src/main/java/fr/openmc/core/features/city/sub/mayor/menu/create/MayorModifyMenu.java @@ -8,7 +8,7 @@ import fr.openmc.core.features.city.sub.mayor.managers.PerkManager; import fr.openmc.core.features.city.sub.mayor.models.MayorCandidate; import fr.openmc.core.features.city.sub.mayor.perks.Perks; -import fr.openmc.core.utils.ColorUtils; +import fr.openmc.core.utils.text.ColorUtils; import net.kyori.adventure.text.Component; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/src/main/java/fr/openmc/core/features/city/sub/mayor/menu/create/PerkChoiceMenu.java b/src/main/java/fr/openmc/core/features/city/sub/mayor/menu/create/PerkChoiceMenu.java index 1274a0ee8..692153137 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/mayor/menu/create/PerkChoiceMenu.java +++ b/src/main/java/fr/openmc/core/features/city/sub/mayor/menu/create/PerkChoiceMenu.java @@ -11,9 +11,9 @@ import fr.openmc.core.features.city.sub.mayor.perks.Perks; import fr.openmc.core.features.city.sub.milestone.rewards.FeaturesRewards; import fr.openmc.core.registry.items.CustomItemRegistry; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/src/main/java/fr/openmc/core/features/city/sub/mayor/menu/npc/MayorNpcMenu.java b/src/main/java/fr/openmc/core/features/city/sub/mayor/menu/npc/MayorNpcMenu.java index 5bca11743..7dad3a117 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/mayor/menu/npc/MayorNpcMenu.java +++ b/src/main/java/fr/openmc/core/features/city/sub/mayor/menu/npc/MayorNpcMenu.java @@ -5,7 +5,6 @@ import fr.openmc.api.menulib.Menu; import fr.openmc.api.menulib.utils.InventorySize; import fr.openmc.api.menulib.utils.ItemBuilder; -import fr.openmc.api.menulib.utils.ItemUtils; import fr.openmc.core.features.city.City; import fr.openmc.core.features.city.CityManager; import fr.openmc.core.features.city.CityPermission; @@ -13,10 +12,10 @@ 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.Perks; -import fr.openmc.core.utils.SkullUtils; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.bukkit.SkullUtils; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.Chunk; import org.bukkit.Material; diff --git a/src/main/java/fr/openmc/core/features/city/sub/mayor/menu/npc/OwnerNpcMenu.java b/src/main/java/fr/openmc/core/features/city/sub/mayor/menu/npc/OwnerNpcMenu.java index a319895a6..4c961daf4 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/mayor/menu/npc/OwnerNpcMenu.java +++ b/src/main/java/fr/openmc/core/features/city/sub/mayor/menu/npc/OwnerNpcMenu.java @@ -5,7 +5,6 @@ import fr.openmc.api.menulib.Menu; import fr.openmc.api.menulib.utils.InventorySize; import fr.openmc.api.menulib.utils.ItemBuilder; -import fr.openmc.api.menulib.utils.ItemUtils; import fr.openmc.core.features.city.City; import fr.openmc.core.features.city.CityManager; import fr.openmc.core.features.city.CityPermission; @@ -14,11 +13,11 @@ 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.Perks; +import fr.openmc.core.utils.bukkit.SkullUtils; import fr.openmc.core.utils.cache.CacheOfflinePlayer; -import fr.openmc.core.utils.SkullUtils; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.Chunk; import org.bukkit.Material; diff --git a/src/main/java/fr/openmc/core/features/city/sub/mayor/models/Mayor.java b/src/main/java/fr/openmc/core/features/city/sub/mayor/models/Mayor.java index ae809fd9f..e87a4a096 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/mayor/models/Mayor.java +++ b/src/main/java/fr/openmc/core/features/city/sub/mayor/models/Mayor.java @@ -3,7 +3,7 @@ import com.j256.ormlite.field.DatabaseField; import com.j256.ormlite.table.DatabaseTable; import fr.openmc.core.features.city.sub.mayor.ElectionType; -import fr.openmc.core.utils.ColorUtils; +import fr.openmc.core.utils.text.ColorUtils; import lombok.Getter; import lombok.Setter; import net.kyori.adventure.text.format.NamedTextColor; diff --git a/src/main/java/fr/openmc/core/features/city/sub/mayor/models/MayorCandidate.java b/src/main/java/fr/openmc/core/features/city/sub/mayor/models/MayorCandidate.java index 3517d32d6..cef8a0930 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/mayor/models/MayorCandidate.java +++ b/src/main/java/fr/openmc/core/features/city/sub/mayor/models/MayorCandidate.java @@ -2,7 +2,7 @@ import com.j256.ormlite.field.DatabaseField; import com.j256.ormlite.table.DatabaseTable; -import fr.openmc.core.utils.ColorUtils; +import fr.openmc.core.utils.text.ColorUtils; import lombok.Getter; import lombok.Setter; import net.kyori.adventure.text.format.NamedTextColor; diff --git a/src/main/java/fr/openmc/core/features/city/sub/mayor/perks/basic/AyweniterPerk.java b/src/main/java/fr/openmc/core/features/city/sub/mayor/perks/basic/AyweniterPerk.java index 98ec6156d..2166db8bb 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/mayor/perks/basic/AyweniterPerk.java +++ b/src/main/java/fr/openmc/core/features/city/sub/mayor/perks/basic/AyweniterPerk.java @@ -7,9 +7,9 @@ import fr.openmc.core.features.city.sub.mayor.perks.Perks; import fr.openmc.core.features.dream.DreamUtils; import fr.openmc.core.registry.items.CustomItemRegistry; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.Material; import org.bukkit.Sound; diff --git a/src/main/java/fr/openmc/core/features/city/sub/mayor/perks/basic/GPSTrackerPerk.java b/src/main/java/fr/openmc/core/features/city/sub/mayor/perks/basic/GPSTrackerPerk.java index 1d79266c6..a8adb0b53 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/mayor/perks/basic/GPSTrackerPerk.java +++ b/src/main/java/fr/openmc/core/features/city/sub/mayor/perks/basic/GPSTrackerPerk.java @@ -6,9 +6,9 @@ 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.Perks; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.Chunk; import org.bukkit.entity.Player; diff --git a/src/main/java/fr/openmc/core/features/city/sub/mayor/perks/basic/IronBloodPerk.java b/src/main/java/fr/openmc/core/features/city/sub/mayor/perks/basic/IronBloodPerk.java index 55258e206..dd7054ef8 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/mayor/perks/basic/IronBloodPerk.java +++ b/src/main/java/fr/openmc/core/features/city/sub/mayor/perks/basic/IronBloodPerk.java @@ -4,10 +4,10 @@ import fr.openmc.core.features.city.City; import fr.openmc.core.features.city.CityManager; import fr.openmc.core.features.city.sub.mascots.utils.MascotUtils; -import fr.openmc.core.utils.LocationUtils; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; +import fr.openmc.core.utils.world.LocationUtils; import net.kyori.adventure.text.Component; import org.bukkit.Bukkit; import org.bukkit.Location; diff --git a/src/main/java/fr/openmc/core/features/city/sub/mayor/perks/event/AgriculturalEssorPerk.java b/src/main/java/fr/openmc/core/features/city/sub/mayor/perks/event/AgriculturalEssorPerk.java index f2a0f0c48..1591933b2 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/mayor/perks/event/AgriculturalEssorPerk.java +++ b/src/main/java/fr/openmc/core/features/city/sub/mayor/perks/event/AgriculturalEssorPerk.java @@ -7,11 +7,11 @@ import fr.openmc.core.features.city.sub.mayor.managers.MayorManager; import fr.openmc.core.features.city.sub.mayor.managers.PerkManager; import fr.openmc.core.features.city.sub.mayor.perks.Perks; -import fr.openmc.core.utils.DateUtils; -import fr.openmc.core.utils.MaterialUtils; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.bukkit.MaterialUtils; +import fr.openmc.core.utils.text.DateUtils; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.Bukkit; import org.bukkit.block.Block; diff --git a/src/main/java/fr/openmc/core/features/city/sub/mayor/perks/event/IdyllicRain.java b/src/main/java/fr/openmc/core/features/city/sub/mayor/perks/event/IdyllicRain.java index a27bf7d3a..f5ffdf8f7 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/mayor/perks/event/IdyllicRain.java +++ b/src/main/java/fr/openmc/core/features/city/sub/mayor/perks/event/IdyllicRain.java @@ -4,7 +4,7 @@ import fr.openmc.core.features.city.City; import fr.openmc.core.features.city.CityManager; import fr.openmc.core.registry.items.CustomItemRegistry; -import fr.openmc.core.utils.ChunkPos; +import fr.openmc.core.utils.world.chunk.ChunkPos; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.NamespacedKey; diff --git a/src/main/java/fr/openmc/core/features/city/sub/mayor/perks/event/ImpotCollection.java b/src/main/java/fr/openmc/core/features/city/sub/mayor/perks/event/ImpotCollection.java index d41a8e915..37d9ce871 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/mayor/perks/event/ImpotCollection.java +++ b/src/main/java/fr/openmc/core/features/city/sub/mayor/perks/event/ImpotCollection.java @@ -5,9 +5,9 @@ import fr.openmc.core.features.economy.BankManager; import fr.openmc.core.features.economy.EconomyManager; import fr.openmc.core.registry.items.CustomItemRegistry; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.Bukkit; import org.bukkit.Location; diff --git a/src/main/java/fr/openmc/core/features/city/sub/mayor/perks/event/MilitaryDissuasion.java b/src/main/java/fr/openmc/core/features/city/sub/mayor/perks/event/MilitaryDissuasion.java index e92add79a..9267722df 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/mayor/perks/event/MilitaryDissuasion.java +++ b/src/main/java/fr/openmc/core/features/city/sub/mayor/perks/event/MilitaryDissuasion.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.utils.ChunkPos; +import fr.openmc.core.utils.world.chunk.ChunkPos; import net.kyori.adventure.text.Component; import org.bukkit.*; import org.bukkit.entity.Entity; diff --git a/src/main/java/fr/openmc/core/features/city/sub/mayor/perks/event/MineralRushPerk.java b/src/main/java/fr/openmc/core/features/city/sub/mayor/perks/event/MineralRushPerk.java index 3aaf2c15e..a15f88286 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/mayor/perks/event/MineralRushPerk.java +++ b/src/main/java/fr/openmc/core/features/city/sub/mayor/perks/event/MineralRushPerk.java @@ -9,11 +9,11 @@ import fr.openmc.core.features.city.sub.mayor.managers.PerkManager; import fr.openmc.core.features.city.sub.mayor.perks.Perks; import fr.openmc.core.registry.items.CustomItemRegistry; -import fr.openmc.core.utils.DateUtils; -import fr.openmc.core.utils.MaterialUtils; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.bukkit.MaterialUtils; +import fr.openmc.core.utils.text.DateUtils; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.Bukkit; import org.bukkit.block.Block; diff --git a/src/main/java/fr/openmc/core/features/city/sub/milestone/commands/AdminCityMilestoneCommands.java b/src/main/java/fr/openmc/core/features/city/sub/milestone/commands/AdminCityMilestoneCommands.java index 457751af4..b4325deab 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/milestone/commands/AdminCityMilestoneCommands.java +++ b/src/main/java/fr/openmc/core/features/city/sub/milestone/commands/AdminCityMilestoneCommands.java @@ -4,9 +4,9 @@ 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.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.entity.Player; import revxrsal.commands.annotation.*; diff --git a/src/main/java/fr/openmc/core/features/city/sub/milestone/listeners/CooldownEndListener.java b/src/main/java/fr/openmc/core/features/city/sub/milestone/listeners/CooldownEndListener.java index 912502cfb..bc70b1327 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/milestone/listeners/CooldownEndListener.java +++ b/src/main/java/fr/openmc/core/features/city/sub/milestone/listeners/CooldownEndListener.java @@ -9,9 +9,9 @@ import fr.openmc.core.features.city.sub.milestone.events.CityUpgradeEvent; import fr.openmc.core.features.city.sub.milestone.rewards.FeaturesRewards; import fr.openmc.core.features.city.sub.statistics.CityStatisticsManager; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.Bukkit; import org.bukkit.event.EventHandler; diff --git a/src/main/java/fr/openmc/core/features/city/sub/milestone/menu/CityMilestoneMenu.java b/src/main/java/fr/openmc/core/features/city/sub/milestone/menu/CityMilestoneMenu.java index 38fa86103..7975571cc 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/milestone/menu/CityMilestoneMenu.java +++ b/src/main/java/fr/openmc/core/features/city/sub/milestone/menu/CityMilestoneMenu.java @@ -10,7 +10,7 @@ import fr.openmc.core.features.city.sub.milestone.CityLevels; import fr.openmc.core.features.city.sub.milestone.CityRequirement; import fr.openmc.core.features.city.sub.milestone.CityRewards; -import fr.openmc.core.utils.DateUtils; +import fr.openmc.core.utils.text.DateUtils; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.TextDecoration; diff --git a/src/main/java/fr/openmc/core/features/city/sub/milestone/requirements/ItemDepositRequirement.java b/src/main/java/fr/openmc/core/features/city/sub/milestone/requirements/ItemDepositRequirement.java index 4e1f8c545..82c8eada6 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/milestone/requirements/ItemDepositRequirement.java +++ b/src/main/java/fr/openmc/core/features/city/sub/milestone/requirements/ItemDepositRequirement.java @@ -5,10 +5,10 @@ import fr.openmc.core.features.city.sub.milestone.CityLevels; import fr.openmc.core.features.city.sub.milestone.CityRequirement; import fr.openmc.core.features.city.sub.statistics.CityStatisticsManager; -import fr.openmc.core.utils.ItemUtils; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.bukkit.ItemUtils; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.TextDecoration; diff --git a/src/main/java/fr/openmc/core/features/city/sub/notation/NotationManager.java b/src/main/java/fr/openmc/core/features/city/sub/notation/NotationManager.java index a4fff03a2..44667d0d2 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/notation/NotationManager.java +++ b/src/main/java/fr/openmc/core/features/city/sub/notation/NotationManager.java @@ -15,8 +15,8 @@ import fr.openmc.core.features.city.sub.notation.models.CityNotation; import fr.openmc.core.features.economy.BankManager; import fr.openmc.core.features.economy.EconomyManager; -import fr.openmc.core.utils.DateUtils; import fr.openmc.core.utils.cache.CacheOfflinePlayer; +import fr.openmc.core.utils.text.DateUtils; import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; import org.bukkit.Statistic; 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 4652b117a..c51f42a63 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 @@ -1,15 +1,15 @@ package fr.openmc.core.features.city.sub.notation.commands; -import fr.openmc.api.input.DialogInput; +import fr.openmc.api.input.dialog.DialogInput; import fr.openmc.core.features.city.City; import fr.openmc.core.features.city.CityManager; import fr.openmc.core.features.city.sub.milestone.rewards.FeaturesRewards; import fr.openmc.core.features.city.sub.notation.NotationManager; import fr.openmc.core.features.city.sub.notation.menu.NotationEditionDialog; -import fr.openmc.core.utils.DateUtils; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.DateUtils; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.entity.Player; import revxrsal.commands.annotation.Command; diff --git a/src/main/java/fr/openmc/core/features/city/sub/notation/commands/NotationCommands.java b/src/main/java/fr/openmc/core/features/city/sub/notation/commands/NotationCommands.java index 80dd4a713..566570b54 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/notation/commands/NotationCommands.java +++ b/src/main/java/fr/openmc/core/features/city/sub/notation/commands/NotationCommands.java @@ -2,10 +2,10 @@ import fr.openmc.core.features.city.sub.notation.NotationManager; import fr.openmc.core.features.city.sub.notation.menu.NotationDialog; -import fr.openmc.core.utils.DateUtils; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.DateUtils; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.entity.Player; import revxrsal.commands.annotation.Command; diff --git a/src/main/java/fr/openmc/core/features/city/sub/notation/listeners/PlayerJoinListener.java b/src/main/java/fr/openmc/core/features/city/sub/notation/listeners/PlayerJoinListener.java index dc166aad9..369ed62e1 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/notation/listeners/PlayerJoinListener.java +++ b/src/main/java/fr/openmc/core/features/city/sub/notation/listeners/PlayerJoinListener.java @@ -4,10 +4,10 @@ import fr.openmc.core.features.city.CityManager; import fr.openmc.core.features.city.sub.notation.NotationManager; import fr.openmc.core.features.city.sub.notation.models.CityNotation; -import fr.openmc.core.utils.DateUtils; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.DateUtils; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.event.ClickEvent; import org.bukkit.entity.Player; diff --git a/src/main/java/fr/openmc/core/features/city/sub/notation/menu/NotationDialog.java b/src/main/java/fr/openmc/core/features/city/sub/notation/menu/NotationDialog.java index c36447249..2f4038d6c 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/notation/menu/NotationDialog.java +++ b/src/main/java/fr/openmc/core/features/city/sub/notation/menu/NotationDialog.java @@ -1,13 +1,13 @@ package fr.openmc.core.features.city.sub.notation.menu; +import fr.openmc.api.input.dialog.ButtonType; 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.city.sub.notation.NotationManager; import fr.openmc.core.features.city.sub.notation.NotationNote; import fr.openmc.core.features.city.sub.notation.models.CityNotation; -import fr.openmc.core.utils.PaddingUtils; -import fr.openmc.core.utils.dialog.ButtonType; +import fr.openmc.core.utils.text.PaddingUtils; import io.papermc.paper.dialog.Dialog; import io.papermc.paper.registry.data.dialog.ActionButton; import io.papermc.paper.registry.data.dialog.DialogBase; @@ -25,7 +25,7 @@ import java.util.ArrayList; import java.util.List; -import static fr.openmc.core.utils.InputUtils.MAX_LENGTH_CITY; +import static fr.openmc.core.utils.text.InputUtils.MAX_LENGTH_CITY; @SuppressWarnings("UnstableApiUsage") public class NotationDialog { diff --git a/src/main/java/fr/openmc/core/features/city/sub/notation/menu/NotationEditionDialog.java b/src/main/java/fr/openmc/core/features/city/sub/notation/menu/NotationEditionDialog.java index bead44263..19f62b0c1 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/notation/menu/NotationEditionDialog.java +++ b/src/main/java/fr/openmc/core/features/city/sub/notation/menu/NotationEditionDialog.java @@ -1,13 +1,13 @@ package fr.openmc.core.features.city.sub.notation.menu; +import fr.openmc.api.input.dialog.ButtonType; import fr.openmc.core.features.city.City; import fr.openmc.core.features.city.sub.notation.NotationManager; import fr.openmc.core.features.city.sub.notation.NotationNote; import fr.openmc.core.features.city.sub.notation.models.CityNotation; -import fr.openmc.core.utils.dialog.ButtonType; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import io.papermc.paper.dialog.Dialog; import io.papermc.paper.registry.data.dialog.ActionButton; import io.papermc.paper.registry.data.dialog.DialogBase; diff --git a/src/main/java/fr/openmc/core/features/city/sub/rank/CityRankAction.java b/src/main/java/fr/openmc/core/features/city/sub/rank/CityRankAction.java index b6c680f28..251d3c42f 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/rank/CityRankAction.java +++ b/src/main/java/fr/openmc/core/features/city/sub/rank/CityRankAction.java @@ -1,6 +1,6 @@ package fr.openmc.core.features.city.sub.rank; -import fr.openmc.api.input.DialogInput; +import fr.openmc.api.input.dialog.DialogInput; import fr.openmc.api.menulib.template.ConfirmMenu; import fr.openmc.core.features.city.City; import fr.openmc.core.features.city.CityManager; @@ -9,9 +9,9 @@ import fr.openmc.core.features.city.sub.milestone.rewards.FeaturesRewards; import fr.openmc.core.features.city.sub.rank.menus.CityRankDetailsMenu; import fr.openmc.core.features.city.sub.rank.menus.CityRankMemberMenu; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.OfflinePlayer; import org.bukkit.entity.Player; 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 38a35b724..0b908cff0 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 @@ -9,9 +9,9 @@ import fr.openmc.core.features.city.sub.milestone.rewards.FeaturesRewards; import fr.openmc.core.features.city.sub.rank.menus.CityRankDetailsMenu; import fr.openmc.core.features.city.sub.rank.menus.CityRanksMenu; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.OfflinePlayer; import org.bukkit.entity.Player; diff --git a/src/main/java/fr/openmc/core/features/city/sub/rank/CityRankCondition.java b/src/main/java/fr/openmc/core/features/city/sub/rank/CityRankCondition.java index aec3f00e1..1d3efa99d 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/rank/CityRankCondition.java +++ b/src/main/java/fr/openmc/core/features/city/sub/rank/CityRankCondition.java @@ -5,9 +5,9 @@ import fr.openmc.core.features.city.models.DBCityRank; import fr.openmc.core.features.city.sub.milestone.rewards.FeaturesRewards; import fr.openmc.core.features.city.sub.milestone.rewards.RankLimitRewards; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.entity.Player; diff --git a/src/main/java/fr/openmc/core/features/city/sub/rank/menus/CityRankAssignMenu.java b/src/main/java/fr/openmc/core/features/city/sub/rank/menus/CityRankAssignMenu.java index 02dbc6439..830ba08d9 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/rank/menus/CityRankAssignMenu.java +++ b/src/main/java/fr/openmc/core/features/city/sub/rank/menus/CityRankAssignMenu.java @@ -8,9 +8,9 @@ import fr.openmc.core.features.city.models.DBCityRank; import fr.openmc.core.features.city.sub.rank.CityRankAction; import fr.openmc.core.utils.cache.CacheOfflinePlayer; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.entity.Player; import org.bukkit.event.inventory.InventoryClickEvent; diff --git a/src/main/java/fr/openmc/core/features/city/sub/rank/menus/CityRankDetailsMenu.java b/src/main/java/fr/openmc/core/features/city/sub/rank/menus/CityRankDetailsMenu.java index bdad63453..3ba90554e 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/rank/menus/CityRankDetailsMenu.java +++ b/src/main/java/fr/openmc/core/features/city/sub/rank/menus/CityRankDetailsMenu.java @@ -11,10 +11,10 @@ import fr.openmc.core.features.city.sub.rank.CityRankCondition; import fr.openmc.core.features.city.sub.rank.CityRankManager; import fr.openmc.core.registry.items.CustomItemRegistry; -import fr.openmc.core.utils.ItemUtils; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.bukkit.ItemUtils; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.TextDecoration; diff --git a/src/main/java/fr/openmc/core/features/city/sub/rank/menus/CityRankIconMenu.java b/src/main/java/fr/openmc/core/features/city/sub/rank/menus/CityRankIconMenu.java index 8c2928738..8c7e9c0ee 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/rank/menus/CityRankIconMenu.java +++ b/src/main/java/fr/openmc/core/features/city/sub/rank/menus/CityRankIconMenu.java @@ -1,7 +1,7 @@ package fr.openmc.core.features.city.sub.rank.menus; import dev.lone.itemsadder.api.CustomStack; -import fr.openmc.api.input.DialogInput; +import fr.openmc.api.input.dialog.DialogInput; import fr.openmc.api.menulib.PaginatedMenu; import fr.openmc.api.menulib.utils.InventorySize; import fr.openmc.api.menulib.utils.ItemBuilder; @@ -9,7 +9,7 @@ import fr.openmc.core.features.city.City; import fr.openmc.core.features.city.models.DBCityRank; import fr.openmc.core.registry.items.CustomItemRegistry; -import fr.openmc.core.utils.ItemUtils; +import fr.openmc.core.utils.bukkit.ItemUtils; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.TextDecoration; import org.bukkit.Material; @@ -24,7 +24,7 @@ import java.util.*; import static fr.openmc.api.menulib.utils.ItemUtils.getDataComponentType; -import static fr.openmc.core.utils.InputUtils.MAX_LENGTH; +import static fr.openmc.core.utils.text.InputUtils.MAX_LENGTH; public class CityRankIconMenu extends PaginatedMenu { diff --git a/src/main/java/fr/openmc/core/features/city/sub/rank/menus/CityRankMemberMenu.java b/src/main/java/fr/openmc/core/features/city/sub/rank/menus/CityRankMemberMenu.java index 6fcfb127b..a6c9e0f78 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/rank/menus/CityRankMemberMenu.java +++ b/src/main/java/fr/openmc/core/features/city/sub/rank/menus/CityRankMemberMenu.java @@ -7,11 +7,11 @@ import fr.openmc.core.features.city.City; import fr.openmc.core.features.city.CityPermission; import fr.openmc.core.features.city.sub.rank.CityRankCondition; -import fr.openmc.core.utils.SkullUtils; +import fr.openmc.core.utils.bukkit.SkullUtils; import fr.openmc.core.utils.cache.CacheOfflinePlayer; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.TextDecoration; import org.bukkit.Material; 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 ae18c59f6..d938fa148 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 @@ -11,9 +11,9 @@ import fr.openmc.core.features.city.models.DBCityRank; import fr.openmc.core.features.city.sub.rank.CityRankCommands; import fr.openmc.core.registry.items.CustomItemRegistry; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.Material; import org.bukkit.entity.Player; 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 6723a5140..076ca76f1 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 @@ -2,7 +2,7 @@ import fr.openmc.core.OMCPlugin; import fr.openmc.core.features.city.City; -import fr.openmc.core.utils.LocationUtils; +import fr.openmc.core.utils.world.LocationUtils; import lombok.Getter; import lombok.Setter; import net.kyori.adventure.text.Component; 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 28c263170..3307d6395 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 @@ -15,7 +15,7 @@ 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.utils.ChunkPos; +import fr.openmc.core.utils.world.chunk.ChunkPos; import net.kyori.adventure.text.Component; import org.bukkit.Bukkit; import org.bukkit.entity.LivingEntity; 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 fcfe4d9fe..e5f054f40 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 @@ -11,9 +11,9 @@ 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.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.TextComponent; import net.kyori.adventure.text.event.ClickEvent; 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 18a71c876..1da6cb942 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 @@ -4,9 +4,9 @@ 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.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.entity.Player; import revxrsal.commands.annotation.Command; 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 ec77f0490..12423961c 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 @@ -10,10 +10,10 @@ import fr.openmc.core.features.city.sub.war.WarPendingDefense; import fr.openmc.core.features.city.sub.war.actions.WarActions; import fr.openmc.core.features.city.sub.war.menu.main.MainWarMenu; -import fr.openmc.core.utils.DateUtils; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.DateUtils; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.entity.Player; import revxrsal.commands.annotation.Command; diff --git a/src/main/java/fr/openmc/core/features/city/sub/war/listeners/TntPlaceListener.java b/src/main/java/fr/openmc/core/features/city/sub/war/listeners/TntPlaceListener.java index ee4bf29a3..c399df2a0 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/war/listeners/TntPlaceListener.java +++ b/src/main/java/fr/openmc/core/features/city/sub/war/listeners/TntPlaceListener.java @@ -6,9 +6,9 @@ import fr.openmc.core.features.city.CityType; import fr.openmc.core.features.city.ProtectionsManager; import fr.openmc.core.features.city.listeners.protections.CityExplosionData; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.Bukkit; import org.bukkit.Location; 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 03bdf532c..277fa3ab8 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 @@ -18,7 +18,7 @@ import fr.openmc.core.features.city.sub.war.menu.MoreInfoMenu; import fr.openmc.core.features.economy.EconomyManager; import fr.openmc.core.registry.items.CustomItemRegistry; -import fr.openmc.core.utils.SkullUtils; +import fr.openmc.core.utils.bukkit.SkullUtils; import fr.openmc.core.utils.cache.PlayerNameCache; import net.kyori.adventure.text.Component; import org.bukkit.Bukkit; diff --git a/src/main/java/fr/openmc/core/features/city/sub/war/menu/main/WarPlayerListMenu.java b/src/main/java/fr/openmc/core/features/city/sub/war/menu/main/WarPlayerListMenu.java index 3a83834a2..bf52b7eae 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/war/menu/main/WarPlayerListMenu.java +++ b/src/main/java/fr/openmc/core/features/city/sub/war/menu/main/WarPlayerListMenu.java @@ -8,7 +8,7 @@ import fr.openmc.core.features.city.CityPermission; import fr.openmc.core.features.city.sub.mayor.managers.MayorManager; import fr.openmc.core.registry.items.CustomItemRegistry; -import fr.openmc.core.utils.SkullUtils; +import fr.openmc.core.utils.bukkit.SkullUtils; import fr.openmc.core.utils.cache.CacheOfflinePlayer; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.TextDecoration; diff --git a/src/main/java/fr/openmc/core/features/city/sub/war/menu/selection/WarChooseParticipantsMenu.java b/src/main/java/fr/openmc/core/features/city/sub/war/menu/selection/WarChooseParticipantsMenu.java index 601f17541..3a8b08040 100644 --- a/src/main/java/fr/openmc/core/features/city/sub/war/menu/selection/WarChooseParticipantsMenu.java +++ b/src/main/java/fr/openmc/core/features/city/sub/war/menu/selection/WarChooseParticipantsMenu.java @@ -9,11 +9,11 @@ import fr.openmc.core.features.city.sub.mayor.managers.MayorManager; import fr.openmc.core.features.city.sub.war.actions.WarActions; import fr.openmc.core.registry.items.CustomItemRegistry; +import fr.openmc.core.utils.bukkit.SkullUtils; import fr.openmc.core.utils.cache.CacheOfflinePlayer; -import fr.openmc.core.utils.SkullUtils; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.TextDecoration; import org.bukkit.Bukkit; diff --git a/src/main/java/fr/openmc/core/features/city/view/CityViewData.java b/src/main/java/fr/openmc/core/features/city/view/CityViewData.java index 538668e0b..2386ef542 100644 --- a/src/main/java/fr/openmc/core/features/city/view/CityViewData.java +++ b/src/main/java/fr/openmc/core/features/city/view/CityViewData.java @@ -1,7 +1,7 @@ package fr.openmc.core.features.city.view; import fr.openmc.core.features.city.City; -import fr.openmc.core.utils.ChunkPos; +import fr.openmc.core.utils.world.chunk.ChunkPos; import io.papermc.paper.threadedregions.scheduler.ScheduledTask; import it.unimi.dsi.fastutil.objects.Object2ObjectMap; import org.jetbrains.annotations.NotNull; 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 05a1e7cbd..7affa5123 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 @@ -4,11 +4,11 @@ import fr.openmc.core.OMCPlugin; import fr.openmc.core.features.city.City; import fr.openmc.core.features.city.CityManager; -import fr.openmc.core.utils.ChunkPos; -import fr.openmc.core.utils.ParticleUtils; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.bukkit.ParticleUtils; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; +import fr.openmc.core.utils.world.chunk.ChunkPos; import io.papermc.paper.threadedregions.scheduler.ScheduledTask; import it.unimi.dsi.fastutil.objects.Object2ObjectMap; import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; diff --git a/src/main/java/fr/openmc/core/features/cube/CubeCommands.java b/src/main/java/fr/openmc/core/features/cube/CubeCommands.java index 0167c6619..cd769f227 100644 --- a/src/main/java/fr/openmc/core/features/cube/CubeCommands.java +++ b/src/main/java/fr/openmc/core/features/cube/CubeCommands.java @@ -2,9 +2,9 @@ import fr.openmc.core.features.cube.multiblocks.MultiBlock; import fr.openmc.core.features.cube.multiblocks.MultiBlockManager; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.Bukkit; import org.bukkit.World; 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 ca264d4e1..7b1aae6cd 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,6 +1,8 @@ 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.LoadAfterItemsAdder; import fr.openmc.core.features.cube.Cube; import fr.openmc.core.features.dream.DreamUtils; import fr.openmc.core.features.dream.generation.DreamDimensionManager; @@ -19,14 +21,15 @@ import java.util.List; import java.util.Map; -public class MultiBlockManager { +public class MultiBlockManager extends Feature implements LoadAfterItemsAdder { private static final OMCPlugin plugin = OMCPlugin.getInstance(); @Getter public static final List multiBlocks = new ArrayList<>(); private static FileConfiguration config = null; private static File file = null; - public static void init() { + @Override + public void init() { file = new File(OMCPlugin.getInstance().getDataFolder() + "/data", "multiblocks.yml"); if (!file.exists()) { plugin.saveResource("data/multiblocks.yml", false); @@ -80,7 +83,12 @@ public static void load() { } } - public static void save() { + @Override + public void save() { + saveConfig(); + } + + public static void saveConfig() { if (config == null) return; List> list = new ArrayList<>(); @@ -116,6 +124,6 @@ public static void save() { public static void register(MultiBlock multiBlock) { multiBlocks.add(multiBlock); - save(); + saveConfig(); } } 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 f19b5ea27..0d5fdad36 100644 --- a/src/main/java/fr/openmc/core/features/displays/TabList.java +++ b/src/main/java/fr/openmc/core/features/displays/TabList.java @@ -10,6 +10,8 @@ import com.comphenix.protocol.wrappers.WrappedChatComponent; 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.NotInUnitTest; import fr.openmc.core.features.dream.DreamUtils; import org.bukkit.Bukkit; import org.bukkit.entity.Player; @@ -18,10 +20,11 @@ import java.util.List; import java.util.UUID; -public class TabList { +public class TabList extends Feature implements NotInUnitTest { private static ProtocolManager protocolManager = null; - public static void init() { + @Override + public void init() { if (Bukkit.getPluginManager().getPlugin("ProtocolLib") != null) protocolManager = ProtocolLibrary.getProtocolManager(); @@ -64,6 +67,11 @@ public void onPacketSending(PacketEvent event) { }); } + @Override + public void save() { + // nothing to save + } + public static void updateHeaderFooter(Player player, String header, String footer) { try { if (protocolManager == null) return; 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 1c1b003fd..93831b4e9 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 @@ -2,11 +2,12 @@ import fr.openmc.core.CommandsManager; import fr.openmc.core.OMCPlugin; +import fr.openmc.core.bootstrap.features.Feature; import fr.openmc.core.features.displays.bossbar.commands.BossBarCommand; import fr.openmc.core.features.milestones.MilestoneUtils; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import lombok.Getter; import net.kyori.adventure.bossbar.BossBar; import net.kyori.adventure.text.Component; @@ -19,7 +20,7 @@ import java.io.File; import java.util.*; -public class BossbarManager { +public class BossbarManager extends Feature { @Getter private static final List helpMessages = new ArrayList<>(); private static final HashMap> activeBossBars = new HashMap<>(); @@ -35,7 +36,8 @@ public class BossbarManager { /** * Initializes the BossbarManager */ - public static void init() { + @Override + public void init() { configFile = new File(OMCPlugin.getInstance().getDataFolder() + "/data", "bossbars.yml"); loadConfig(); loadDefaultMessages(); @@ -50,6 +52,11 @@ public static void init() { ); } + @Override + public void save() { + // nothing to save + } + /** * Loads configuration from bossbars.yml file * Creates the file if it doesn't exist diff --git a/src/main/java/fr/openmc/core/features/displays/bossbar/commands/BossBarCommand.java b/src/main/java/fr/openmc/core/features/displays/bossbar/commands/BossBarCommand.java index 7d81d9960..7641aff26 100644 --- a/src/main/java/fr/openmc/core/features/displays/bossbar/commands/BossBarCommand.java +++ b/src/main/java/fr/openmc/core/features/displays/bossbar/commands/BossBarCommand.java @@ -1,9 +1,9 @@ package fr.openmc.core.features.displays.bossbar.commands; import fr.openmc.core.features.displays.bossbar.BossbarManager; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.event.ClickEvent; import net.kyori.adventure.text.event.HoverEvent; diff --git a/src/main/java/fr/openmc/core/features/displays/holograms/HologramInfo.java b/src/main/java/fr/openmc/core/features/displays/holograms/HologramInfo.java index f759aca4d..9414bcc5d 100644 --- a/src/main/java/fr/openmc/core/features/displays/holograms/HologramInfo.java +++ b/src/main/java/fr/openmc/core/features/displays/holograms/HologramInfo.java @@ -1,6 +1,6 @@ package fr.openmc.core.features.displays.holograms; -import fr.openmc.core.utils.entities.TextDisplay; +import fr.openmc.core.utils.world.entities.TextDisplay; import java.io.File; 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 4a714ef39..8a38db7a6 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 @@ -2,9 +2,12 @@ import fr.openmc.core.CommandsManager; 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.features.types.NotInUnitTest; import fr.openmc.core.features.displays.holograms.commands.HologramCommand; import fr.openmc.core.features.milestones.tutorial.TutorialHologram; -import fr.openmc.core.utils.entities.TextDisplay; +import fr.openmc.core.utils.world.entities.TextDisplay; import net.kyori.adventure.text.Component; import org.bukkit.Location; import org.bukkit.configuration.file.FileConfiguration; @@ -20,14 +23,26 @@ import java.util.List; import java.util.Objects; -public class HologramLoader { +public class HologramLoader extends Feature implements NotInUnitTest, LoadAfterItemsAdder { public static final HashMap displays = new HashMap<>(); private static BukkitTask taskTimer; + private static File hologramFolder; - public static final File hologramFolder = new File(OMCPlugin.getInstance().getDataFolder(), "data/holograms"); + public static File getHologramFolder() { + if (hologramFolder == null) { + OMCPlugin plugin = OMCPlugin.getInstance(); + if (plugin == null) { + throw new IllegalStateException("OMCPlugin instance not initialized"); + } + hologramFolder = new File(plugin.getDataFolder(), "data/holograms"); + } + return hologramFolder; + } - public static void init() { + @Override + public void init() { + File hologramFolder = getHologramFolder(); hologramFolder.mkdirs(); CommandsManager.getHandler().register( @@ -42,6 +57,11 @@ public static void init() { HologramLoader.loadAllFromFolder(hologramFolder); } + @Override + public void save() { + HologramLoader.unloadAll(); + } + public static void updateHologramsViewers() { taskTimer = new BukkitRunnable() { @Override @@ -55,6 +75,7 @@ public void run() { } public static void registerHolograms(Hologram... holograms) { + File hologramFolder = getHologramFolder(); for (Hologram hologram : holograms) { if (hologram == null) continue; @@ -134,6 +155,7 @@ public static void unloadAll() { } public static void setHologramLocation(String hologramName, Location location) throws IOException { + File hologramFolder = getHologramFolder(); HologramInfo hologramInfo = displays.get(hologramName); FileConfiguration hologramConfig = YamlConfiguration.loadConfiguration(hologramInfo.file()); hologramConfig.set("location", location); diff --git a/src/main/java/fr/openmc/core/features/displays/holograms/commands/HologramCommand.java b/src/main/java/fr/openmc/core/features/displays/holograms/commands/HologramCommand.java index 17340fa22..2192e75e7 100644 --- a/src/main/java/fr/openmc/core/features/displays/holograms/commands/HologramCommand.java +++ b/src/main/java/fr/openmc/core/features/displays/holograms/commands/HologramCommand.java @@ -2,9 +2,9 @@ import fr.openmc.core.features.displays.holograms.HologramLoader; import fr.openmc.core.features.displays.holograms.commands.autocomplete.HologramAutoComplete; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; diff --git a/src/main/java/fr/openmc/core/features/displays/scoreboards/BaseScoreboard.java b/src/main/java/fr/openmc/core/features/displays/scoreboards/BaseScoreboard.java index 309d9d9d8..5e502ff9d 100644 --- a/src/main/java/fr/openmc/core/features/displays/scoreboards/BaseScoreboard.java +++ b/src/main/java/fr/openmc/core/features/displays/scoreboards/BaseScoreboard.java @@ -8,7 +8,7 @@ import net.kyori.adventure.text.minimessage.MiniMessage; import org.bukkit.entity.Player; -import static fr.openmc.core.utils.messages.MessagesManager.textToSmall; +import static fr.openmc.core.utils.text.messages.MessagesManager.textToSmall; public abstract class BaseScoreboard { protected static final boolean canShowLogo = ItemsAdderHook.isHasItemAdder(); 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 d8cdc82fd..e747e4656 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 @@ -5,6 +5,8 @@ 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.NotInUnitTest; 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; @@ -15,14 +17,15 @@ import java.util.*; -public class ScoreboardManager implements Listener { +public class ScoreboardManager extends Feature implements Listener, NotInUnitTest { public static final ObjectCacheRepository boardCache = new ObjectCacheRepositoryImpl(); private static final List scoreboards = new ArrayList<>(); private static GlobalTeamManager globalTeamManager; private static final Map> lastUpdate = new HashMap<>(); - public static void init() { + @Override + public void init() { OMCPlugin.registerEvents(new ScoreboardListener()); registerScoreboard( @@ -43,6 +46,11 @@ public static void init() { globalTeamManager = new GlobalTeamManager(boardCache); } + @Override + public void save() { + // nothing to save + } + public static void updateAllBoards() { long now = System.currentTimeMillis(); diff --git a/src/main/java/fr/openmc/core/features/displays/scoreboards/sb/CityWarScoreboard.java b/src/main/java/fr/openmc/core/features/displays/scoreboards/sb/CityWarScoreboard.java index 76a4efecb..c146b6e52 100644 --- a/src/main/java/fr/openmc/core/features/displays/scoreboards/sb/CityWarScoreboard.java +++ b/src/main/java/fr/openmc/core/features/displays/scoreboards/sb/CityWarScoreboard.java @@ -7,9 +7,9 @@ import fr.openmc.core.features.city.sub.war.War; import fr.openmc.core.features.city.sub.war.WarManager; import fr.openmc.core.features.displays.scoreboards.BaseScoreboard; -import fr.openmc.core.utils.DateUtils; -import fr.openmc.core.utils.DirectionUtils; import fr.openmc.core.utils.MathUtils; +import fr.openmc.core.utils.text.DateUtils; +import fr.openmc.core.utils.text.DirectionUtils; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.TextColor; @@ -25,7 +25,7 @@ import java.util.ArrayList; import java.util.List; -import static fr.openmc.core.utils.messages.MessagesManager.textToSmall; +import static fr.openmc.core.utils.text.messages.MessagesManager.textToSmall; import static net.kyori.adventure.text.Component.empty; import static net.kyori.adventure.text.Component.text; 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 81e835944..8b688a3b6 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 @@ -17,7 +17,7 @@ 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.utils.DateUtils; +import fr.openmc.core.utils.text.DateUtils; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.TextColor; @@ -29,7 +29,7 @@ import java.util.ArrayList; import java.util.List; -import static fr.openmc.core.utils.messages.MessagesManager.textToSmall; +import static fr.openmc.core.utils.text.messages.MessagesManager.textToSmall; import static net.kyori.adventure.text.Component.*; public class MainScoreboard extends BaseScoreboard { diff --git a/src/main/java/fr/openmc/core/features/displays/scoreboards/sb/RestartScoreboard.java b/src/main/java/fr/openmc/core/features/displays/scoreboards/sb/RestartScoreboard.java index 9558a7b96..2835c419a 100644 --- a/src/main/java/fr/openmc/core/features/displays/scoreboards/sb/RestartScoreboard.java +++ b/src/main/java/fr/openmc/core/features/displays/scoreboards/sb/RestartScoreboard.java @@ -3,7 +3,7 @@ import fr.openmc.api.scoreboard.SternalBoard; import fr.openmc.core.commands.utils.Restart; import fr.openmc.core.features.displays.scoreboards.BaseScoreboard; -import fr.openmc.core.utils.DateUtils; +import fr.openmc.core.utils.text.DateUtils; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; import org.bukkit.entity.Player; @@ -11,7 +11,7 @@ import java.util.ArrayList; import java.util.List; -import static fr.openmc.core.utils.messages.MessagesManager.textToSmall; +import static fr.openmc.core.utils.text.messages.MessagesManager.textToSmall; import static net.kyori.adventure.text.Component.empty; import static net.kyori.adventure.text.Component.text; 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 ec28869e2..304f4514c 100644 --- a/src/main/java/fr/openmc/core/features/dream/DreamManager.java +++ b/src/main/java/fr/openmc/core/features/dream/DreamManager.java @@ -6,6 +6,9 @@ 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.DatabaseFeature; +import fr.openmc.core.bootstrap.features.types.LoadAfterItemsAdder; import fr.openmc.core.commands.utils.SpawnManager; import fr.openmc.core.features.city.City; import fr.openmc.core.features.city.CityManager; @@ -35,14 +38,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.utils.LocationUtils; -import fr.openmc.core.utils.serializer.BukkitSerializer; +import fr.openmc.core.utils.bukkit.serializer.BukkitSerializer; +import fr.openmc.core.utils.world.LocationUtils; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.World; import org.bukkit.block.Biome; import org.bukkit.entity.Player; -import org.bukkit.event.inventory.InventoryCloseEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; @@ -51,7 +53,7 @@ import java.util.HashMap; import java.util.UUID; -public class DreamManager { +public class DreamManager extends Feature implements DatabaseFeature, LoadAfterItemsAdder { // ** CONSTANTS ** public static final Long BASE_DREAM_TIME = 300L; @@ -63,7 +65,8 @@ public class DreamManager { private static Dao dreamPlayerDao; private static Dao savePlayerDao; - public static void init() { + @Override + public void init() { // ** LISTENERS ** OMCPlugin.registerEvents( new PlayerChangeWorldListener(), @@ -109,7 +112,16 @@ public static void init() { loadAllPlayerSaveData(); } - public static void initDB(ConnectionSource connectionSource) throws SQLException { + @Override + public void save() { + DreamManager.saveAllPlayerSaveData(); + DreamManager.saveAllDreamPlayerData(); + + SingularityManager.disable(); + } + + @Override + public void initDB(ConnectionSource connectionSource) throws SQLException { TableUtils.createTableIfNotExists(connectionSource, DBDreamPlayer.class); dreamPlayerDao = DaoManager.createDao(connectionSource, DBDreamPlayer.class); @@ -119,13 +131,6 @@ public static void initDB(ConnectionSource connectionSource) throws SQLException SingularityManager.initDB(connectionSource); } - public static void disable() { - DreamManager.saveAllPlayerSaveData(); - DreamManager.saveAllDreamPlayerData(); - - SingularityManager.disable(); - } - private static void loadAllPlayerSaveData() { try { playerSaveData.clear(); diff --git a/src/main/java/fr/openmc/core/features/dream/DreamUtils.java b/src/main/java/fr/openmc/core/features/dream/DreamUtils.java index 6ffa02da0..427739a29 100644 --- a/src/main/java/fr/openmc/core/features/dream/DreamUtils.java +++ b/src/main/java/fr/openmc/core/features/dream/DreamUtils.java @@ -2,10 +2,10 @@ import fr.openmc.core.features.dream.generation.DreamDimensionManager; import fr.openmc.core.features.dream.models.db.DreamPlayer; -import fr.openmc.core.utils.DateUtils; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.DateUtils; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.Location; import org.bukkit.World; diff --git a/src/main/java/fr/openmc/core/features/dream/commands/DreamCommands.java b/src/main/java/fr/openmc/core/features/dream/commands/DreamCommands.java index 9cfacd6bb..ba0ce3fa8 100644 --- a/src/main/java/fr/openmc/core/features/dream/commands/DreamCommands.java +++ b/src/main/java/fr/openmc/core/features/dream/commands/DreamCommands.java @@ -3,9 +3,9 @@ import fr.openmc.core.OMCPlugin; import fr.openmc.core.features.dream.DreamUtils; import fr.openmc.core.features.dream.events.DreamEndEvent; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.Bukkit; import org.bukkit.entity.Player; diff --git a/src/main/java/fr/openmc/core/features/dream/commands/DreamItemCommand.java b/src/main/java/fr/openmc/core/features/dream/commands/DreamItemCommand.java index e49576887..999badb45 100644 --- a/src/main/java/fr/openmc/core/features/dream/commands/DreamItemCommand.java +++ b/src/main/java/fr/openmc/core/features/dream/commands/DreamItemCommand.java @@ -3,9 +3,9 @@ import fr.openmc.core.features.dream.commands.autocomplete.DreamItemAutoComplete; import fr.openmc.core.features.dream.models.registry.items.DreamItem; import fr.openmc.core.features.dream.registries.DreamItemRegistry; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; diff --git a/src/main/java/fr/openmc/core/features/dream/displays/DreamScoreboard.java b/src/main/java/fr/openmc/core/features/dream/displays/DreamScoreboard.java index 53108870e..29580f74c 100644 --- a/src/main/java/fr/openmc/core/features/dream/displays/DreamScoreboard.java +++ b/src/main/java/fr/openmc/core/features/dream/displays/DreamScoreboard.java @@ -10,7 +10,7 @@ import fr.openmc.core.features.dream.generation.structures.DreamStructure; import fr.openmc.core.features.dream.generation.structures.DreamStructuresManager; import fr.openmc.core.features.dream.models.db.DreamPlayer; -import fr.openmc.core.utils.DateUtils; +import fr.openmc.core.utils.text.DateUtils; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.TextColor; @@ -21,7 +21,7 @@ import java.util.ArrayList; import java.util.List; -import static fr.openmc.core.utils.messages.MessagesManager.textToSmall; +import static fr.openmc.core.utils.text.messages.MessagesManager.textToSmall; import static net.kyori.adventure.text.Component.empty; import static net.kyori.adventure.text.Component.text; diff --git a/src/main/java/fr/openmc/core/features/dream/generation/DreamBiome.java b/src/main/java/fr/openmc/core/features/dream/generation/DreamBiome.java index 0610563ea..99387e12f 100644 --- a/src/main/java/fr/openmc/core/features/dream/generation/DreamBiome.java +++ b/src/main/java/fr/openmc/core/features/dream/generation/DreamBiome.java @@ -9,7 +9,7 @@ import org.bukkit.block.Biome; import org.jetbrains.annotations.NotNull; -import static fr.openmc.core.utils.messages.MessagesManager.textToSmall; +import static fr.openmc.core.utils.text.messages.MessagesManager.textToSmall; @Getter public enum DreamBiome { diff --git a/src/main/java/fr/openmc/core/features/dream/generation/DreamDimensionManager.java b/src/main/java/fr/openmc/core/features/dream/generation/DreamDimensionManager.java index a16972a62..678fddfc2 100644 --- a/src/main/java/fr/openmc/core/features/dream/generation/DreamDimensionManager.java +++ b/src/main/java/fr/openmc/core/features/dream/generation/DreamDimensionManager.java @@ -13,8 +13,8 @@ import fr.openmc.core.features.dream.generation.structures.cloud.CloudCastleStructure; import fr.openmc.core.features.dream.generation.structures.glacite.BaseCampStructure; import fr.openmc.core.features.dream.generation.structures.soulforest.SoulAltarStructure; -import fr.openmc.core.utils.structure.FeaturesPopulator; -import fr.openmc.core.utils.structure.SchematicsUtils; +import fr.openmc.core.utils.world.structure.FeaturesPopulator; +import fr.openmc.core.utils.world.structure.SchematicsUtils; import org.bukkit.Bukkit; import org.bukkit.GameRule; import org.bukkit.World; diff --git a/src/main/java/fr/openmc/core/features/dream/generation/populators/glacite/CavePopulator.java b/src/main/java/fr/openmc/core/features/dream/generation/populators/glacite/CavePopulator.java index 066c42ed3..8a06ae1c1 100644 --- a/src/main/java/fr/openmc/core/features/dream/generation/populators/glacite/CavePopulator.java +++ b/src/main/java/fr/openmc/core/features/dream/generation/populators/glacite/CavePopulator.java @@ -1,6 +1,6 @@ package fr.openmc.core.features.dream.generation.populators.glacite; -import fr.openmc.core.utils.structure.FeaturesPopulator; +import fr.openmc.core.utils.world.structure.FeaturesPopulator; import org.bukkit.Chunk; import org.bukkit.Location; import org.bukkit.Material; diff --git a/src/main/java/fr/openmc/core/features/dream/generation/populators/glacite/GlaciteGeodePopulator.java b/src/main/java/fr/openmc/core/features/dream/generation/populators/glacite/GlaciteGeodePopulator.java index f4105cb73..edcf15d3c 100644 --- a/src/main/java/fr/openmc/core/features/dream/generation/populators/glacite/GlaciteGeodePopulator.java +++ b/src/main/java/fr/openmc/core/features/dream/generation/populators/glacite/GlaciteGeodePopulator.java @@ -1,7 +1,7 @@ package fr.openmc.core.features.dream.generation.populators.glacite; -import fr.openmc.core.utils.structure.FeaturesPopulator; -import fr.openmc.core.utils.structure.StructureUtils; +import fr.openmc.core.utils.world.structure.FeaturesPopulator; +import fr.openmc.core.utils.world.structure.StructureUtils; import org.bukkit.Chunk; import org.bukkit.Location; import org.bukkit.World; diff --git a/src/main/java/fr/openmc/core/features/dream/generation/populators/mud/RockPopulator.java b/src/main/java/fr/openmc/core/features/dream/generation/populators/mud/RockPopulator.java index cd408611a..b02178b09 100644 --- a/src/main/java/fr/openmc/core/features/dream/generation/populators/mud/RockPopulator.java +++ b/src/main/java/fr/openmc/core/features/dream/generation/populators/mud/RockPopulator.java @@ -1,8 +1,8 @@ package fr.openmc.core.features.dream.generation.populators.mud; import fr.openmc.core.features.dream.generation.DreamBiome; -import fr.openmc.core.utils.structure.FeaturesPopulator; -import fr.openmc.core.utils.structure.StructureUtils; +import fr.openmc.core.utils.world.structure.FeaturesPopulator; +import fr.openmc.core.utils.world.structure.StructureUtils; import org.bukkit.Chunk; import org.bukkit.Location; import org.bukkit.World; diff --git a/src/main/java/fr/openmc/core/features/dream/generation/populators/plains/PlainsTreePopulator.java b/src/main/java/fr/openmc/core/features/dream/generation/populators/plains/PlainsTreePopulator.java index 4811d1944..54a3258c5 100644 --- a/src/main/java/fr/openmc/core/features/dream/generation/populators/plains/PlainsTreePopulator.java +++ b/src/main/java/fr/openmc/core/features/dream/generation/populators/plains/PlainsTreePopulator.java @@ -1,8 +1,8 @@ package fr.openmc.core.features.dream.generation.populators.plains; import fr.openmc.core.features.dream.generation.DreamBiome; -import fr.openmc.core.utils.structure.FeaturesPopulator; -import fr.openmc.core.utils.structure.StructureUtils; +import fr.openmc.core.utils.world.structure.FeaturesPopulator; +import fr.openmc.core.utils.world.structure.StructureUtils; import org.bukkit.Chunk; import org.bukkit.Location; import org.bukkit.World; diff --git a/src/main/java/fr/openmc/core/features/dream/generation/populators/soulforest/PillarPopulator.java b/src/main/java/fr/openmc/core/features/dream/generation/populators/soulforest/PillarPopulator.java index 5c9ee96bd..af103759d 100644 --- a/src/main/java/fr/openmc/core/features/dream/generation/populators/soulforest/PillarPopulator.java +++ b/src/main/java/fr/openmc/core/features/dream/generation/populators/soulforest/PillarPopulator.java @@ -1,8 +1,8 @@ package fr.openmc.core.features.dream.generation.populators.soulforest; import fr.openmc.core.features.dream.generation.DreamBiome; -import fr.openmc.core.utils.structure.FeaturesPopulator; -import fr.openmc.core.utils.structure.StructureUtils; +import fr.openmc.core.utils.world.structure.FeaturesPopulator; +import fr.openmc.core.utils.world.structure.StructureUtils; import org.bukkit.Chunk; import org.bukkit.Location; import org.bukkit.World; diff --git a/src/main/java/fr/openmc/core/features/dream/generation/populators/soulforest/SoulTreePopulator.java b/src/main/java/fr/openmc/core/features/dream/generation/populators/soulforest/SoulTreePopulator.java index 3a9d79f0c..0e2591ed9 100644 --- a/src/main/java/fr/openmc/core/features/dream/generation/populators/soulforest/SoulTreePopulator.java +++ b/src/main/java/fr/openmc/core/features/dream/generation/populators/soulforest/SoulTreePopulator.java @@ -1,8 +1,8 @@ package fr.openmc.core.features.dream.generation.populators.soulforest; import fr.openmc.core.features.dream.generation.DreamBiome; -import fr.openmc.core.utils.structure.FeaturesPopulator; -import fr.openmc.core.utils.structure.StructureUtils; +import fr.openmc.core.utils.world.structure.FeaturesPopulator; +import fr.openmc.core.utils.world.structure.StructureUtils; import org.bukkit.Chunk; import org.bukkit.Location; import org.bukkit.World; diff --git a/src/main/java/fr/openmc/core/features/dream/generation/structures/DreamStructurePopulator.java b/src/main/java/fr/openmc/core/features/dream/generation/structures/DreamStructurePopulator.java index f23d4e54e..569265948 100644 --- a/src/main/java/fr/openmc/core/features/dream/generation/structures/DreamStructurePopulator.java +++ b/src/main/java/fr/openmc/core/features/dream/generation/structures/DreamStructurePopulator.java @@ -7,7 +7,7 @@ import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.session.ClipboardHolder; import fr.openmc.core.OMCPlugin; -import fr.openmc.core.utils.structure.SchematicsUtils; +import fr.openmc.core.utils.world.structure.SchematicsUtils; import org.bukkit.Chunk; import org.bukkit.Location; import org.bukkit.World; diff --git a/src/main/java/fr/openmc/core/features/dream/generation/structures/cloud/CloudCastleStructure.java b/src/main/java/fr/openmc/core/features/dream/generation/structures/cloud/CloudCastleStructure.java index bfa973a71..9b9c817e9 100644 --- a/src/main/java/fr/openmc/core/features/dream/generation/structures/cloud/CloudCastleStructure.java +++ b/src/main/java/fr/openmc/core/features/dream/generation/structures/cloud/CloudCastleStructure.java @@ -4,7 +4,7 @@ import fr.openmc.core.features.dream.generation.biomes.CloudChunkGenerator; import fr.openmc.core.features.dream.generation.structures.DreamStructure; import fr.openmc.core.features.dream.generation.structures.DreamStructurePopulator; -import fr.openmc.core.utils.structure.SchematicsUtils; +import fr.openmc.core.utils.world.structure.SchematicsUtils; import org.bukkit.Chunk; import org.bukkit.Location; import org.bukkit.World; diff --git a/src/main/java/fr/openmc/core/features/dream/generation/structures/glacite/BaseCampStructure.java b/src/main/java/fr/openmc/core/features/dream/generation/structures/glacite/BaseCampStructure.java index 6d8eff4ca..fc538e8b0 100644 --- a/src/main/java/fr/openmc/core/features/dream/generation/structures/glacite/BaseCampStructure.java +++ b/src/main/java/fr/openmc/core/features/dream/generation/structures/glacite/BaseCampStructure.java @@ -4,7 +4,7 @@ import fr.openmc.core.features.dream.generation.biomes.GlaciteCaveChunkGenerator; import fr.openmc.core.features.dream.generation.structures.DreamStructure; import fr.openmc.core.features.dream.generation.structures.DreamStructurePopulator; -import fr.openmc.core.utils.structure.SchematicsUtils; +import fr.openmc.core.utils.world.structure.SchematicsUtils; import org.bukkit.Chunk; import org.bukkit.Location; import org.bukkit.World; diff --git a/src/main/java/fr/openmc/core/features/dream/generation/structures/soulforest/SoulAltarStructure.java b/src/main/java/fr/openmc/core/features/dream/generation/structures/soulforest/SoulAltarStructure.java index e758889a5..4ceb20278 100644 --- a/src/main/java/fr/openmc/core/features/dream/generation/structures/soulforest/SoulAltarStructure.java +++ b/src/main/java/fr/openmc/core/features/dream/generation/structures/soulforest/SoulAltarStructure.java @@ -4,7 +4,7 @@ import fr.openmc.core.features.dream.generation.DreamBiome; import fr.openmc.core.features.dream.generation.structures.DreamStructure; import fr.openmc.core.features.dream.generation.structures.DreamStructurePopulator; -import fr.openmc.core.utils.structure.SchematicsUtils; +import fr.openmc.core.utils.world.structure.SchematicsUtils; import org.bukkit.Chunk; import org.bukkit.Location; import org.bukkit.World; diff --git a/src/main/java/fr/openmc/core/features/dream/listeners/biomes/PlayerEnteredBiome.java b/src/main/java/fr/openmc/core/features/dream/listeners/biomes/PlayerEnteredBiome.java index 6f35dacdf..8dc6ca979 100644 --- a/src/main/java/fr/openmc/core/features/dream/listeners/biomes/PlayerEnteredBiome.java +++ b/src/main/java/fr/openmc/core/features/dream/listeners/biomes/PlayerEnteredBiome.java @@ -5,10 +5,10 @@ import fr.openmc.core.features.dream.DreamUtils; import fr.openmc.core.features.dream.generation.DreamBiome; import fr.openmc.core.features.dream.models.db.DBDreamPlayer; -import fr.openmc.core.utils.ParticleUtils; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.bukkit.ParticleUtils; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.Bukkit; import org.bukkit.Particle; diff --git a/src/main/java/fr/openmc/core/features/dream/listeners/orb/PlayerObtainOrb.java b/src/main/java/fr/openmc/core/features/dream/listeners/orb/PlayerObtainOrb.java index 74d3980c4..848df9bbc 100644 --- a/src/main/java/fr/openmc/core/features/dream/listeners/orb/PlayerObtainOrb.java +++ b/src/main/java/fr/openmc/core/features/dream/listeners/orb/PlayerObtainOrb.java @@ -12,9 +12,9 @@ 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.DreamItemRegistry; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.Keyed; import org.bukkit.NamespacedKey; diff --git a/src/main/java/fr/openmc/core/features/dream/listeners/registry/DreamItemDropsListener.java b/src/main/java/fr/openmc/core/features/dream/listeners/registry/DreamItemDropsListener.java index 306adeef6..1c5176a9b 100644 --- a/src/main/java/fr/openmc/core/features/dream/listeners/registry/DreamItemDropsListener.java +++ b/src/main/java/fr/openmc/core/features/dream/listeners/registry/DreamItemDropsListener.java @@ -3,9 +3,9 @@ import fr.openmc.core.features.dream.models.registry.items.DreamItem; import fr.openmc.core.features.dream.models.registry.items.DreamRarity; import fr.openmc.core.features.dream.registries.DreamItemRegistry; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; import org.bukkit.event.EventHandler; diff --git a/src/main/java/fr/openmc/core/features/dream/mecanism/altar/AltarListener.java b/src/main/java/fr/openmc/core/features/dream/mecanism/altar/AltarListener.java index 1a4efca85..08bb45fc0 100644 --- a/src/main/java/fr/openmc/core/features/dream/mecanism/altar/AltarListener.java +++ b/src/main/java/fr/openmc/core/features/dream/mecanism/altar/AltarListener.java @@ -3,9 +3,9 @@ import fr.openmc.core.features.dream.models.registry.items.DreamItem; import fr.openmc.core.features.dream.registries.DreamBlocksRegistry; import fr.openmc.core.features.dream.registries.DreamItemRegistry; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.Location; import org.bukkit.block.Block; diff --git a/src/main/java/fr/openmc/core/features/dream/mecanism/altar/AltarManager.java b/src/main/java/fr/openmc/core/features/dream/mecanism/altar/AltarManager.java index e2a4dd274..d47692b17 100644 --- a/src/main/java/fr/openmc/core/features/dream/mecanism/altar/AltarManager.java +++ b/src/main/java/fr/openmc/core/features/dream/mecanism/altar/AltarManager.java @@ -3,10 +3,10 @@ import fr.openmc.core.OMCPlugin; import fr.openmc.core.features.dream.models.registry.items.DreamItem; import fr.openmc.core.features.dream.registries.DreamItemRegistry; -import fr.openmc.core.utils.ItemUtils; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.bukkit.ItemUtils; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.Bukkit; import org.bukkit.Location; diff --git a/src/main/java/fr/openmc/core/features/dream/mecanism/cloudfishing/CloudFishingManager.java b/src/main/java/fr/openmc/core/features/dream/mecanism/cloudfishing/CloudFishingManager.java index f0be271ba..f7d9635c0 100644 --- a/src/main/java/fr/openmc/core/features/dream/mecanism/cloudfishing/CloudFishingManager.java +++ b/src/main/java/fr/openmc/core/features/dream/mecanism/cloudfishing/CloudFishingManager.java @@ -4,10 +4,8 @@ import fr.openmc.core.features.dream.generation.biomes.CloudChunkGenerator; import fr.openmc.core.registry.loottable.CustomLootTable; import fr.openmc.core.registry.loottable.CustomLootTableRegistry; -import fr.openmc.core.utils.ParticleUtils; +import fr.openmc.core.utils.bukkit.ParticleUtils; import lombok.Getter; -import net.kyori.adventure.key.Key; -import net.minecraft.network.chat.ClickEvent; import org.bukkit.Location; import org.bukkit.Particle; import org.bukkit.Sound; diff --git a/src/main/java/fr/openmc/core/features/dream/mecanism/cloudfishing/PlayerFishListener.java b/src/main/java/fr/openmc/core/features/dream/mecanism/cloudfishing/PlayerFishListener.java index 7264fc9d6..54326dcdf 100644 --- a/src/main/java/fr/openmc/core/features/dream/mecanism/cloudfishing/PlayerFishListener.java +++ b/src/main/java/fr/openmc/core/features/dream/mecanism/cloudfishing/PlayerFishListener.java @@ -3,9 +3,9 @@ import fr.openmc.core.OMCPlugin; import fr.openmc.core.features.dream.DreamUtils; import fr.openmc.core.registry.loottable.CustomLootTable; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.Location; import org.bukkit.Sound; diff --git a/src/main/java/fr/openmc/core/features/dream/mecanism/cold/ColdManager.java b/src/main/java/fr/openmc/core/features/dream/mecanism/cold/ColdManager.java index b79fd6a6e..761e46f16 100644 --- a/src/main/java/fr/openmc/core/features/dream/mecanism/cold/ColdManager.java +++ b/src/main/java/fr/openmc/core/features/dream/mecanism/cold/ColdManager.java @@ -3,8 +3,8 @@ import fr.openmc.core.OMCPlugin; import fr.openmc.core.features.dream.models.registry.items.DreamEquipableItem; import fr.openmc.core.features.dream.registries.DreamItemRegistry; -import fr.openmc.core.utils.ParticleUtils; -import fr.openmc.core.utils.PlayerUtils; +import fr.openmc.core.utils.bukkit.ParticleUtils; +import fr.openmc.core.utils.bukkit.PlayerUtils; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.NamespacedKey; diff --git a/src/main/java/fr/openmc/core/features/dream/mecanism/metaldetector/MetalDetectorListener.java b/src/main/java/fr/openmc/core/features/dream/mecanism/metaldetector/MetalDetectorListener.java index d3d17e093..ccafd9201 100644 --- a/src/main/java/fr/openmc/core/features/dream/mecanism/metaldetector/MetalDetectorListener.java +++ b/src/main/java/fr/openmc/core/features/dream/mecanism/metaldetector/MetalDetectorListener.java @@ -5,10 +5,10 @@ import fr.openmc.core.features.dream.events.MetalDetectorLootEvent; import fr.openmc.core.features.dream.generation.DreamBiome; import fr.openmc.core.registry.loottable.CustomLootTable; -import fr.openmc.core.utils.LocationUtils; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; +import fr.openmc.core.utils.world.LocationUtils; import net.kyori.adventure.text.Component; import org.bukkit.Bukkit; import org.bukkit.Location; diff --git a/src/main/java/fr/openmc/core/features/dream/mecanism/metaldetector/MetalDetectorTask.java b/src/main/java/fr/openmc/core/features/dream/mecanism/metaldetector/MetalDetectorTask.java index bc1bb3dd2..e68bbbc67 100644 --- a/src/main/java/fr/openmc/core/features/dream/mecanism/metaldetector/MetalDetectorTask.java +++ b/src/main/java/fr/openmc/core/features/dream/mecanism/metaldetector/MetalDetectorTask.java @@ -3,7 +3,7 @@ import fr.openmc.core.features.dream.DreamUtils; import fr.openmc.core.features.dream.models.registry.items.DreamItem; import fr.openmc.core.features.dream.registries.DreamItemRegistry; -import fr.openmc.core.utils.DirectionUtils; +import fr.openmc.core.utils.text.DirectionUtils; import lombok.Getter; import lombok.Setter; import net.kyori.adventure.text.Component; diff --git a/src/main/java/fr/openmc/core/features/dream/mecanism/singularity/SingularityContents.java b/src/main/java/fr/openmc/core/features/dream/mecanism/singularity/SingularityContents.java index 5dc737986..afc01883a 100644 --- a/src/main/java/fr/openmc/core/features/dream/mecanism/singularity/SingularityContents.java +++ b/src/main/java/fr/openmc/core/features/dream/mecanism/singularity/SingularityContents.java @@ -3,7 +3,7 @@ import com.j256.ormlite.field.DataType; import com.j256.ormlite.field.DatabaseField; import com.j256.ormlite.table.DatabaseTable; -import fr.openmc.core.utils.serializer.BukkitSerializer; +import fr.openmc.core.utils.bukkit.serializer.BukkitSerializer; import lombok.Getter; import org.bukkit.inventory.ItemStack; diff --git a/src/main/java/fr/openmc/core/features/dream/mecanism/tradernpc/GlaciteTradeMenu.java b/src/main/java/fr/openmc/core/features/dream/mecanism/tradernpc/GlaciteTradeMenu.java index 04d22bbac..995db504b 100644 --- a/src/main/java/fr/openmc/core/features/dream/mecanism/tradernpc/GlaciteTradeMenu.java +++ b/src/main/java/fr/openmc/core/features/dream/mecanism/tradernpc/GlaciteTradeMenu.java @@ -8,10 +8,10 @@ import fr.openmc.core.features.dream.events.GlaciteTradeEvent; import fr.openmc.core.features.dream.models.db.DreamPlayer; import fr.openmc.core.features.dream.registries.DreamItemRegistry; -import fr.openmc.core.utils.ItemUtils; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.bukkit.ItemUtils; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer; 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 530c48d22..fe90d80c6 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 @@ -12,10 +12,10 @@ import fr.openmc.core.features.dream.generation.structures.DreamStructure; import fr.openmc.core.features.dream.generation.structures.DreamStructuresManager; import fr.openmc.core.features.dream.mecanism.cold.ColdManager; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; -import fr.openmc.core.utils.serializer.BukkitSerializer; +import fr.openmc.core.utils.bukkit.serializer.BukkitSerializer; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import lombok.Getter; import lombok.Setter; import net.kyori.adventure.text.Component; diff --git a/src/main/java/fr/openmc/core/features/dream/registries/enchantements/Soulbound.java b/src/main/java/fr/openmc/core/features/dream/registries/enchantements/Soulbound.java index 9f4f6dc13..6fce42e1c 100644 --- a/src/main/java/fr/openmc/core/features/dream/registries/enchantements/Soulbound.java +++ b/src/main/java/fr/openmc/core/features/dream/registries/enchantements/Soulbound.java @@ -3,10 +3,10 @@ import fr.openmc.api.cooldown.DynamicCooldownManager; import fr.openmc.core.features.dream.models.registry.DreamEnchantment; import fr.openmc.core.registry.enchantments.CustomEnchantmentRegistry; -import fr.openmc.core.utils.DateUtils; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.DateUtils; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import io.papermc.paper.registry.data.EnchantmentRegistryEntry; import io.papermc.paper.registry.keys.tags.ItemTypeTagKeys; import io.papermc.paper.registry.tag.TagKey; diff --git a/src/main/java/fr/openmc/core/features/dream/registries/items/tools/MetalDetector.java b/src/main/java/fr/openmc/core/features/dream/registries/items/tools/MetalDetector.java index 51aaa320f..2de3df077 100644 --- a/src/main/java/fr/openmc/core/features/dream/registries/items/tools/MetalDetector.java +++ b/src/main/java/fr/openmc/core/features/dream/registries/items/tools/MetalDetector.java @@ -6,9 +6,9 @@ import fr.openmc.core.features.dream.models.registry.items.DreamItem; import fr.openmc.core.features.dream.models.registry.items.DreamRarity; import fr.openmc.core.registry.items.options.UsableItem; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.Location; import org.bukkit.Material; diff --git a/src/main/java/fr/openmc/core/features/dream/registries/items/tools/MeteoWand.java b/src/main/java/fr/openmc/core/features/dream/registries/items/tools/MeteoWand.java index 737188db1..2c90ea6b8 100644 --- a/src/main/java/fr/openmc/core/features/dream/registries/items/tools/MeteoWand.java +++ b/src/main/java/fr/openmc/core/features/dream/registries/items/tools/MeteoWand.java @@ -5,10 +5,10 @@ import fr.openmc.core.features.dream.models.registry.items.DreamItem; import fr.openmc.core.features.dream.models.registry.items.DreamRarity; import fr.openmc.core.registry.items.options.UsableItem; -import fr.openmc.core.utils.DateUtils; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.DateUtils; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.Material; import org.bukkit.Sound; diff --git a/src/main/java/fr/openmc/core/features/dream/registries/mobs/Breezy.java b/src/main/java/fr/openmc/core/features/dream/registries/mobs/Breezy.java index 78800de75..a8ca81b91 100644 --- a/src/main/java/fr/openmc/core/features/dream/registries/mobs/Breezy.java +++ b/src/main/java/fr/openmc/core/features/dream/registries/mobs/Breezy.java @@ -4,7 +4,7 @@ import fr.openmc.core.features.dream.DreamUtils; import fr.openmc.core.features.dream.generation.DreamDimensionManager; import fr.openmc.core.features.dream.models.registry.DreamMob; -import fr.openmc.core.utils.ParticleUtils; +import fr.openmc.core.utils.bukkit.ParticleUtils; import org.bukkit.*; import org.bukkit.entity.*; import org.bukkit.event.EventHandler; diff --git a/src/main/java/fr/openmc/core/features/dream/registries/mobs/Soul.java b/src/main/java/fr/openmc/core/features/dream/registries/mobs/Soul.java index 25bd55e4b..ef137f724 100644 --- a/src/main/java/fr/openmc/core/features/dream/registries/mobs/Soul.java +++ b/src/main/java/fr/openmc/core/features/dream/registries/mobs/Soul.java @@ -6,7 +6,7 @@ import fr.openmc.core.features.dream.registries.DreamMobsRegistry; import fr.openmc.core.registry.loottable.CustomLoot; import fr.openmc.core.utils.RandomUtils; -import fr.openmc.core.utils.SkullUtils; +import fr.openmc.core.utils.bukkit.SkullUtils; import net.kyori.adventure.text.Component; import org.bukkit.Bukkit; import org.bukkit.Location; 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 6086a0850..e410db647 100644 --- a/src/main/java/fr/openmc/core/features/economy/BankManager.java +++ b/src/main/java/fr/openmc/core/features/economy/BankManager.java @@ -6,6 +6,8 @@ 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.DatabaseFeature; import fr.openmc.core.features.city.City; import fr.openmc.core.features.city.CityManager; import fr.openmc.core.features.city.sub.bank.CityBankManager; @@ -16,11 +18,11 @@ 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.utils.InputUtils; import fr.openmc.core.utils.cache.CacheOfflinePlayer; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.InputUtils; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import lombok.Getter; import net.kyori.adventure.text.Component; import org.bukkit.Bukkit; @@ -37,19 +39,26 @@ import java.util.Map; import java.util.UUID; -public class BankManager { +public class BankManager extends Feature implements DatabaseFeature { @Getter private static Map banks; private static Dao banksDao; - public static void init() { + @Override + public void init() { banks = loadAllBanks(); CommandsManager.getHandler().register(new BankCommands()); updateInterestTimer(); } - public static void initDB(ConnectionSource connectionSource) throws SQLException { + @Override + public void save() { + // nothing to save + } + + @Override + public void initDB(ConnectionSource connectionSource) throws SQLException { TableUtils.createTableIfNotExists(connectionSource, Bank.class); banksDao = DaoManager.createDao(connectionSource, Bank.class); } 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 1c2ee977e..908bf0410 100644 --- a/src/main/java/fr/openmc/core/features/economy/EconomyManager.java +++ b/src/main/java/fr/openmc/core/features/economy/EconomyManager.java @@ -7,6 +7,8 @@ import dev.lone.itemsadder.api.FontImages.FontImageWrapper; import fr.openmc.api.hooks.ItemsAdderHook; import fr.openmc.core.CommandsManager; +import fr.openmc.core.bootstrap.features.Feature; +import fr.openmc.core.bootstrap.features.types.DatabaseFeature; import fr.openmc.core.features.economy.commands.Baltop; import fr.openmc.core.features.economy.commands.History; import fr.openmc.core.features.economy.commands.Money; @@ -14,25 +16,19 @@ import fr.openmc.core.features.economy.models.EconomyPlayer; import lombok.Getter; +import javax.annotation.Nullable; import java.math.BigDecimal; import java.sql.SQLException; import java.text.DecimalFormat; import java.text.NumberFormat; import java.util.*; -import javax.annotation.Nullable; - -public class EconomyManager { +public class EconomyManager extends Feature implements DatabaseFeature { @Getter private static Map balances; private static Dao playersDao; - public static void initDB(ConnectionSource connectionSource) throws SQLException { - TableUtils.createTableIfNotExists(connectionSource, EconomyPlayer.class); - playersDao = DaoManager.createDao(connectionSource, EconomyPlayer.class); - } - private static final DecimalFormat decimalFormat = new DecimalFormat("#.##"); private static final NavigableMap suffixes = new TreeMap<>(Map.of( 1_000L, "k", @@ -42,7 +38,8 @@ public static void initDB(ConnectionSource connectionSource) throws SQLException 1_000_000_000_000_000L, "Qa", 1_000_000_000_000_000_000L, "Qi")); - public static void init() { + @Override + public void init() { balances = loadAllBalances(); CommandsManager.getHandler().register( @@ -53,6 +50,17 @@ public static void init() { ); } + @Override + public void save() { + // nothing to save + } + + @Override + public void initDB(ConnectionSource connectionSource) throws SQLException { + TableUtils.createTableIfNotExists(connectionSource, EconomyPlayer.class); + playersDao = DaoManager.createDao(connectionSource, EconomyPlayer.class); + } + public static double getBalance(UUID playerUUID) { EconomyPlayer bank = getPlayerBank(playerUUID); return bank.getBalance(); 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 4264ca030..bdf576dd8 100644 --- a/src/main/java/fr/openmc/core/features/economy/TransactionsManager.java +++ b/src/main/java/fr/openmc/core/features/economy/TransactionsManager.java @@ -6,6 +6,8 @@ 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.DatabaseFeature; import fr.openmc.core.features.analytics.Stats; import org.bukkit.Bukkit; @@ -14,10 +16,21 @@ import java.util.Objects; import java.util.UUID; -public class TransactionsManager { +public class TransactionsManager extends Feature implements DatabaseFeature { private static Dao transactionsDao; - public static void initDB(ConnectionSource connectionSource) throws SQLException { + @Override + protected void init() { + // nothing to init + } + + @Override + protected void save() { + // nothing to save + } + + @Override + public void initDB(ConnectionSource connectionSource) throws SQLException { TableUtils.createTableIfNotExists(connectionSource, Transaction.class); transactionsDao = DaoManager.createDao(connectionSource, Transaction.class); } diff --git a/src/main/java/fr/openmc/core/features/economy/commands/BankCommands.java b/src/main/java/fr/openmc/core/features/economy/commands/BankCommands.java index cd6583d42..20971f5c1 100644 --- a/src/main/java/fr/openmc/core/features/economy/commands/BankCommands.java +++ b/src/main/java/fr/openmc/core/features/economy/commands/BankCommands.java @@ -7,9 +7,9 @@ import fr.openmc.core.features.economy.BankManager; import fr.openmc.core.features.economy.EconomyManager; import fr.openmc.core.features.economy.menu.PersonalBankMenu; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.entity.Player; import revxrsal.commands.annotation.*; diff --git a/src/main/java/fr/openmc/core/features/economy/commands/Money.java b/src/main/java/fr/openmc/core/features/economy/commands/Money.java index 187da6bb9..d056d07b8 100644 --- a/src/main/java/fr/openmc/core/features/economy/commands/Money.java +++ b/src/main/java/fr/openmc/core/features/economy/commands/Money.java @@ -2,9 +2,9 @@ import fr.openmc.core.commands.autocomplete.OnlinePlayerAutoComplete; import fr.openmc.core.features.economy.EconomyManager; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.OfflinePlayer; import org.bukkit.command.CommandSender; diff --git a/src/main/java/fr/openmc/core/features/economy/commands/Pay.java b/src/main/java/fr/openmc/core/features/economy/commands/Pay.java index 182032e67..20e9ef7ef 100644 --- a/src/main/java/fr/openmc/core/features/economy/commands/Pay.java +++ b/src/main/java/fr/openmc/core/features/economy/commands/Pay.java @@ -2,9 +2,9 @@ import fr.openmc.core.commands.autocomplete.OnlinePlayerAutoComplete; import fr.openmc.core.features.economy.EconomyManager; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.entity.Player; import revxrsal.commands.annotation.*; diff --git a/src/main/java/fr/openmc/core/features/economy/menu/PersonalBankDepositMenu.java b/src/main/java/fr/openmc/core/features/economy/menu/PersonalBankDepositMenu.java index b2ea47191..dae8cb219 100644 --- a/src/main/java/fr/openmc/core/features/economy/menu/PersonalBankDepositMenu.java +++ b/src/main/java/fr/openmc/core/features/economy/menu/PersonalBankDepositMenu.java @@ -1,6 +1,6 @@ package fr.openmc.core.features.economy.menu; -import fr.openmc.api.input.DialogInput; +import fr.openmc.api.input.dialog.DialogInput; import fr.openmc.api.menulib.Menu; import fr.openmc.api.menulib.utils.InventorySize; import fr.openmc.api.menulib.utils.ItemBuilder; @@ -19,7 +19,7 @@ import java.util.List; import java.util.Map; -import static fr.openmc.core.utils.InputUtils.MAX_LENGTH; +import static fr.openmc.core.utils.text.InputUtils.MAX_LENGTH; public class PersonalBankDepositMenu extends Menu { 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 722ebd4bd..0c8e2bd17 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 @@ -10,10 +10,10 @@ import fr.openmc.core.features.city.sub.milestone.rewards.PlayerBankLimitRewards; import fr.openmc.core.features.economy.BankManager; import fr.openmc.core.features.economy.EconomyManager; -import fr.openmc.core.utils.DateUtils; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.DateUtils; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.TextDecoration; import org.bukkit.Material; diff --git a/src/main/java/fr/openmc/core/features/economy/menu/PersonalBankWithdrawMenu.java b/src/main/java/fr/openmc/core/features/economy/menu/PersonalBankWithdrawMenu.java index 5722cfa6f..71a8caaa8 100644 --- a/src/main/java/fr/openmc/core/features/economy/menu/PersonalBankWithdrawMenu.java +++ b/src/main/java/fr/openmc/core/features/economy/menu/PersonalBankWithdrawMenu.java @@ -1,6 +1,6 @@ package fr.openmc.core.features.economy.menu; -import fr.openmc.api.input.DialogInput; +import fr.openmc.api.input.dialog.DialogInput; import fr.openmc.api.menulib.Menu; import fr.openmc.api.menulib.utils.InventorySize; import fr.openmc.api.menulib.utils.ItemBuilder; @@ -19,7 +19,7 @@ import java.util.List; import java.util.Map; -import static fr.openmc.core.utils.InputUtils.MAX_LENGTH; +import static fr.openmc.core.utils.text.InputUtils.MAX_LENGTH; public class PersonalBankWithdrawMenu extends Menu { 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 f845ebf68..1491f9f6a 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,6 +9,8 @@ import de.oliver.fancynpcs.api.NpcManager; import fr.openmc.api.hooks.FancyNpcsHook; import fr.openmc.core.OMCPlugin; +import fr.openmc.core.bootstrap.features.Feature; +import fr.openmc.core.bootstrap.features.types.DatabaseFeature; import fr.openmc.core.features.economy.EconomyManager; import fr.openmc.core.features.events.contents.halloween.listeners.HalloweenNPCListener; import fr.openmc.core.features.events.contents.halloween.models.HalloweenData; @@ -35,17 +37,22 @@ import java.util.*; @SuppressWarnings("UnstableApiUsage") -public class HalloweenManager { +public class HalloweenManager extends Feature implements DatabaseFeature { private static Object2ObjectMap halloweenData; private static Dao halloweenDataDao; - public static void init() { + public void init() { if (FancyNpcsHook.isHasFancyNpc()) Bukkit.getPluginManager().registerEvents(new HalloweenNPCListener(), OMCPlugin.getInstance()); halloweenData = loadAllHalloweenDatas(); } + @Override + public void save() { + // nothing to save + } + public static void depositPumpkins(UUID playerUUID, int amount) { HalloweenData data = halloweenData.get(playerUUID); data.depositPumpkins(amount); @@ -67,7 +74,8 @@ public static Object2ObjectMap getAllHalloweenData() { return halloweenData; } - public static void initDB(ConnectionSource connectionSource) throws SQLException { + @Override + public void initDB(ConnectionSource connectionSource) throws SQLException { TableUtils.createTableIfNotExists(connectionSource, HalloweenData.class); halloweenDataDao = DaoManager.createDao(connectionSource, HalloweenData.class); } diff --git a/src/main/java/fr/openmc/core/features/events/contents/halloween/menus/HalloweenPumpkinDepositMenu.java b/src/main/java/fr/openmc/core/features/events/contents/halloween/menus/HalloweenPumpkinDepositMenu.java index 6b25b72c1..30b571286 100644 --- a/src/main/java/fr/openmc/core/features/events/contents/halloween/menus/HalloweenPumpkinDepositMenu.java +++ b/src/main/java/fr/openmc/core/features/events/contents/halloween/menus/HalloweenPumpkinDepositMenu.java @@ -4,10 +4,10 @@ import fr.openmc.api.menulib.utils.InventorySize; import fr.openmc.api.menulib.utils.ItemBuilder; import fr.openmc.core.features.events.contents.halloween.managers.HalloweenManager; -import fr.openmc.core.utils.ItemUtils; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.bukkit.ItemUtils; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.TextColor; 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 7441bd546..ce561164d 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 @@ -5,11 +5,14 @@ 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.DatabaseFeature; +import fr.openmc.core.bootstrap.features.types.LoadAfterItemsAdder; 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.features.events.contents.weeklyevents.models.WeeklyEventPhase; import fr.openmc.core.features.events.contents.weeklyevents.models.WeeklyEventsData; -import fr.openmc.core.utils.DateUtils; +import fr.openmc.core.utils.text.DateUtils; import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer; import org.bukkit.Bukkit; import org.bukkit.scheduler.BukkitTask; @@ -17,7 +20,7 @@ import java.sql.SQLException; import java.util.List; -public class WeeklyEventsManager { +public class WeeklyEventsManager extends Feature implements LoadAfterItemsAdder, DatabaseFeature { private static final List EVENTS = List.of( new Contest() @@ -32,7 +35,8 @@ public class WeeklyEventsManager { * Au restart : si on est déjà le bon jour pour la phase courante et que l'event * était actif, on relance l'action immédiatement. */ - public static void init() { + @Override + public void init() { data = load(); WeeklyEventPhase currentPhase = getCurrentPhase(); @@ -44,10 +48,16 @@ public static void init() { scheduleNextPhase(); } + @Override + public void save() { + // nothing to save + } + /** * Initialise la BDD : crée la table si nécessaire, charge les données, gère le cas restart */ - public static void initDB(ConnectionSource connectionSource) throws SQLException { + @Override + public void initDB(ConnectionSource connectionSource) throws SQLException { dao = DaoManager.createDao(connectionSource, WeeklyEventsData.class); TableUtils.createTableIfNotExists(connectionSource, WeeklyEventsData.class); } diff --git a/src/main/java/fr/openmc/core/features/events/contents/weeklyevents/contents/contest/commands/ContestCommand.java b/src/main/java/fr/openmc/core/features/events/contents/weeklyevents/contents/contest/commands/ContestCommand.java index 9f82c3ea3..2f1f18c35 100644 --- a/src/main/java/fr/openmc/core/features/events/contents/weeklyevents/contents/contest/commands/ContestCommand.java +++ b/src/main/java/fr/openmc/core/features/events/contents/weeklyevents/contents/contest/commands/ContestCommand.java @@ -13,10 +13,10 @@ import fr.openmc.core.features.events.contents.weeklyevents.contents.contest.menu.ContributionMenu; import fr.openmc.core.features.events.contents.weeklyevents.contents.contest.menu.VoteMenu; import fr.openmc.core.features.events.contents.weeklyevents.models.WeeklyEventPhase; -import fr.openmc.core.utils.DateUtils; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.DateUtils; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.entity.Player; 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 8b33069e2..00998d02e 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 @@ -5,9 +5,14 @@ import com.j256.ormlite.support.ConnectionSource; import com.j256.ormlite.table.TableUtils; import fr.openmc.api.hooks.ItemsAdderHook; +import fr.openmc.api.hooks.WorldGuardHook; import fr.openmc.api.menulib.Menu; import fr.openmc.core.CommandsManager; import fr.openmc.core.OMCPlugin; +import fr.openmc.core.bootstrap.features.Feature; +import fr.openmc.core.bootstrap.features.types.DatabaseFeature; +import fr.openmc.core.bootstrap.features.types.LoadAfterItemsAdder; +import fr.openmc.core.bootstrap.integration.DatabaseManager; 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; @@ -21,10 +26,9 @@ import fr.openmc.core.features.leaderboards.LeaderboardManager; import fr.openmc.core.features.mailboxes.MailboxManager; import fr.openmc.core.registry.items.CustomItemRegistry; -import fr.openmc.core.utils.ColorUtils; -import fr.openmc.core.utils.ParticleUtils; +import fr.openmc.core.utils.bukkit.ParticleUtils; import fr.openmc.core.utils.cache.CacheOfflinePlayer; -import fr.openmc.core.utils.database.DatabaseManager; +import fr.openmc.core.utils.text.ColorUtils; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.event.ClickEvent; import net.kyori.adventure.text.format.NamedTextColor; @@ -47,7 +51,7 @@ import static fr.openmc.core.features.mailboxes.utils.MailboxUtils.getHoverEvent; -public class ContestManager { +public class ContestManager extends Feature implements DatabaseFeature, LoadAfterItemsAdder { public static ContestData data; public static Map dataPlayer = new HashMap<>(); @@ -74,7 +78,8 @@ public class ContestManager { * - Initialise les données globales et les joueurs * - Programme le lancement et la fin des différentes phases du contest */ - public static void init() { + @Override + public void init() { // ** LISTENERS ** if (ItemsAdderHook.isHasItemAdder()) { OMCPlugin.registerEvents( @@ -93,6 +98,17 @@ public static void init() { // ** LOAD DATAS ** initContestData(); loadContestPlayerData(); + + // ** PARTICLE REGION ** + if (WorldGuardHook.isHasWorldGuard()) { + ParticleUtils.spawnContestParticlesInRegion("spawn", Bukkit.getWorld("world"), 10, 70, 135); + } + } + + @Override + public void save() { + ContestManager.saveContestData(); + ContestManager.saveContestPlayerData(); } private static Dao contestDao; @@ -102,7 +118,8 @@ public static void init() { * Initialise la base de données pour les contests et les joueurs * (création des tables si elles n’existent pas encore) */ - public static void initDB(ConnectionSource connectionSource) throws SQLException { + @Override + public void initDB(ConnectionSource connectionSource) throws SQLException { TableUtils.createTableIfNotExists(connectionSource, ContestData.class); contestDao = DaoManager.createDao(connectionSource, ContestData.class); diff --git a/src/main/java/fr/openmc/core/features/events/contents/weeklyevents/contents/contest/menu/ContributionMenu.java b/src/main/java/fr/openmc/core/features/events/contents/weeklyevents/contents/contest/menu/ContributionMenu.java index b3b4300d9..19eeeac92 100644 --- a/src/main/java/fr/openmc/core/features/events/contents/weeklyevents/contents/contest/menu/ContributionMenu.java +++ b/src/main/java/fr/openmc/core/features/events/contents/weeklyevents/contents/contest/menu/ContributionMenu.java @@ -9,11 +9,11 @@ import fr.openmc.core.features.events.contents.weeklyevents.contents.contest.managers.ContestManager; import fr.openmc.core.features.events.contents.weeklyevents.contents.contest.managers.ContestPlayerManager; import fr.openmc.core.registry.items.CustomItemRegistry; -import fr.openmc.core.utils.ColorUtils; -import fr.openmc.core.utils.ItemUtils; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.bukkit.ItemUtils; +import fr.openmc.core.utils.text.ColorUtils; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.TextDecoration; @@ -26,7 +26,7 @@ import java.util.*; -import static fr.openmc.core.utils.ItemUtils.isSimilar; +import static fr.openmc.core.utils.bukkit.ItemUtils.isSimilar; public class ContributionMenu extends Menu { diff --git a/src/main/java/fr/openmc/core/features/events/contents/weeklyevents/contents/contest/menu/TradeMenu.java b/src/main/java/fr/openmc/core/features/events/contents/weeklyevents/contents/contest/menu/TradeMenu.java index 0f567f2fe..9e210b6d7 100644 --- a/src/main/java/fr/openmc/core/features/events/contents/weeklyevents/contents/contest/menu/TradeMenu.java +++ b/src/main/java/fr/openmc/core/features/events/contents/weeklyevents/contents/contest/menu/TradeMenu.java @@ -11,10 +11,10 @@ import fr.openmc.core.features.events.contents.weeklyevents.contents.contest.managers.TradeYMLManager; import fr.openmc.core.features.mailboxes.MailboxManager; import fr.openmc.core.registry.items.CustomItemRegistry; -import fr.openmc.core.utils.ItemUtils; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.bukkit.ItemUtils; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.TranslatableComponent; import net.kyori.adventure.text.format.NamedTextColor; diff --git a/src/main/java/fr/openmc/core/features/events/contents/weeklyevents/contents/contest/menu/VoteMenu.java b/src/main/java/fr/openmc/core/features/events/contents/weeklyevents/contents/contest/menu/VoteMenu.java index 6fd2860ad..c03cd09be 100644 --- a/src/main/java/fr/openmc/core/features/events/contents/weeklyevents/contents/contest/menu/VoteMenu.java +++ b/src/main/java/fr/openmc/core/features/events/contents/weeklyevents/contents/contest/menu/VoteMenu.java @@ -7,10 +7,10 @@ import fr.openmc.api.menulib.utils.ItemBuilder; import fr.openmc.core.features.events.contents.weeklyevents.contents.contest.managers.ContestManager; import fr.openmc.core.features.events.contents.weeklyevents.contents.contest.models.ContestPlayer; -import fr.openmc.core.utils.ColorUtils; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.ColorUtils; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.TextDecoration; diff --git a/src/main/java/fr/openmc/core/features/friend/FriendCommand.java b/src/main/java/fr/openmc/core/features/friend/FriendCommand.java index 903d7683a..f9d4a552a 100644 --- a/src/main/java/fr/openmc/core/features/friend/FriendCommand.java +++ b/src/main/java/fr/openmc/core/features/friend/FriendCommand.java @@ -8,9 +8,9 @@ import fr.openmc.core.features.friend.autocomplete.FriendsRequestAutoComplete; import fr.openmc.core.features.settings.PlayerSettingsManager; import fr.openmc.core.utils.cache.CacheOfflinePlayer; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.TextComponent; import net.kyori.adventure.text.event.ClickEvent; diff --git a/src/main/java/fr/openmc/core/features/friend/FriendRequest.java b/src/main/java/fr/openmc/core/features/friend/FriendRequest.java index 4fdf9b87e..686a1401b 100644 --- a/src/main/java/fr/openmc/core/features/friend/FriendRequest.java +++ b/src/main/java/fr/openmc/core/features/friend/FriendRequest.java @@ -2,9 +2,9 @@ import fr.openmc.core.OMCPlugin; import fr.openmc.core.utils.cache.CacheOfflinePlayer; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.Bukkit; import org.bukkit.entity.Player; 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 b33e6a1e3..181b9b69d 100644 --- a/src/main/java/fr/openmc/core/features/friend/FriendSQLManager.java +++ b/src/main/java/fr/openmc/core/features/friend/FriendSQLManager.java @@ -7,6 +7,8 @@ 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.DatabaseFeature; import java.sql.SQLException; import java.sql.Timestamp; @@ -16,11 +18,22 @@ import java.util.UUID; import java.util.concurrent.CompletableFuture; -public class FriendSQLManager { +public class FriendSQLManager extends Feature implements DatabaseFeature { private static Dao friendsDao; - public static void initDB(ConnectionSource connectionSource) throws SQLException { + @Override + protected void init() { + // nothing to init + } + + @Override + protected void save() { + // nothing to save + } + + @Override + public void initDB(ConnectionSource connectionSource) throws SQLException { TableUtils.createTableIfNotExists(connectionSource, Friend.class); friendsDao = DaoManager.createDao(connectionSource, Friend.class); } diff --git a/src/main/java/fr/openmc/core/features/homes/HomeUpgradeManager.java b/src/main/java/fr/openmc/core/features/homes/HomeUpgradeManager.java index 17ee8990f..e893578bb 100644 --- a/src/main/java/fr/openmc/core/features/homes/HomeUpgradeManager.java +++ b/src/main/java/fr/openmc/core/features/homes/HomeUpgradeManager.java @@ -4,10 +4,10 @@ import fr.openmc.core.features.economy.EconomyManager; import fr.openmc.core.features.homes.events.HomeUpgradeEvent; import fr.openmc.core.registry.items.CustomItemRegistry; -import fr.openmc.core.utils.ItemUtils; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.bukkit.ItemUtils; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.Bukkit; import org.bukkit.entity.Player; 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 3d0921222..227cd7165 100644 --- a/src/main/java/fr/openmc/core/features/homes/HomesManager.java +++ b/src/main/java/fr/openmc/core/features/homes/HomesManager.java @@ -5,12 +5,13 @@ import com.j256.ormlite.support.ConnectionSource; 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.DatabaseFeature; +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.utils.database.DatabaseManager; import lombok.Getter; import org.bukkit.Location; @@ -20,14 +21,13 @@ import java.util.UUID; @Getter -public class HomesManager { - - private static boolean isInitialized = false; +public class HomesManager extends Feature implements DatabaseFeature { public static final List homes = new ArrayList<>(); public static final List homeLimits = new ArrayList<>(); - public static void init() { + @Override + public void init() { DisabledWorldHome.init(); CommandsManager.getHandler().register( @@ -42,11 +42,10 @@ public static void init() { loadHomeLimit(); loadHomes(); - - isInitialized = true; } - public static void saveHomesData() { + @Override + public void save() { saveHomes(); saveHomeLimit(); } @@ -114,7 +113,8 @@ public static void updateHomeLimit(UUID playerUUID) { private static Dao homesDao; private static Dao limitsDao; - public static void initDB(ConnectionSource connectionSource) throws SQLException { + @Override + public void initDB(ConnectionSource connectionSource) throws SQLException { TableUtils.createTableIfNotExists(connectionSource, Home.class); homesDao = DaoManager.createDao(connectionSource, Home.class); @@ -135,10 +135,6 @@ private static void loadHomeLimit() { } private static void saveHomeLimit() { - if (!isInitialized) { - OMCPlugin.getInstance().getSLF4JLogger().warn("Tentative de sauvegarde des HomeLimits avant l'initialisation du manager, opération ignorée."); - return; - } try { TableUtils.clearTable(DatabaseManager.getConnectionSource(), HomeLimit.class); limitsDao.create(homeLimits); @@ -156,10 +152,6 @@ private static void loadHomes() { } private static void saveHomes() { - if (!isInitialized) { - OMCPlugin.getInstance().getSLF4JLogger().warn("Tentative de sauvegarde des Homes avant l'initialisation du manager, opération ignorée."); - return; - } try { TableUtils.clearTable(DatabaseManager.getConnectionSource(), Home.class); for (Home home : homes) { diff --git a/src/main/java/fr/openmc/core/features/homes/command/DelHomeCommand.java b/src/main/java/fr/openmc/core/features/homes/command/DelHomeCommand.java index 538b439dc..2d6819546 100644 --- a/src/main/java/fr/openmc/core/features/homes/command/DelHomeCommand.java +++ b/src/main/java/fr/openmc/core/features/homes/command/DelHomeCommand.java @@ -3,9 +3,9 @@ import fr.openmc.core.features.homes.HomesManager; import fr.openmc.core.features.homes.command.autocomplete.HomeAutoComplete; import fr.openmc.core.features.homes.models.Home; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; diff --git a/src/main/java/fr/openmc/core/features/homes/command/HomeWorldCommand.java b/src/main/java/fr/openmc/core/features/homes/command/HomeWorldCommand.java index f5a817f8f..555134250 100644 --- a/src/main/java/fr/openmc/core/features/homes/command/HomeWorldCommand.java +++ b/src/main/java/fr/openmc/core/features/homes/command/HomeWorldCommand.java @@ -3,9 +3,9 @@ import fr.openmc.core.features.homes.command.autocomplete.HomeWorldAddAutoComplete; import fr.openmc.core.features.homes.command.autocomplete.HomeWorldRemoveAutoComplete; import fr.openmc.core.features.homes.world.DisabledWorldHome; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.Bukkit; import org.bukkit.World; diff --git a/src/main/java/fr/openmc/core/features/homes/command/RelocateHomeCommand.java b/src/main/java/fr/openmc/core/features/homes/command/RelocateHomeCommand.java index 8200d2ab5..6b051ca31 100644 --- a/src/main/java/fr/openmc/core/features/homes/command/RelocateHomeCommand.java +++ b/src/main/java/fr/openmc/core/features/homes/command/RelocateHomeCommand.java @@ -5,9 +5,9 @@ import fr.openmc.core.features.homes.command.autocomplete.HomeAutoComplete; import fr.openmc.core.features.homes.models.Home; import fr.openmc.core.features.homes.world.DisabledWorldHome; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.Bukkit; import org.bukkit.Location; diff --git a/src/main/java/fr/openmc/core/features/homes/command/RenameHomeCommand.java b/src/main/java/fr/openmc/core/features/homes/command/RenameHomeCommand.java index 29f41c413..c41e14f5f 100644 --- a/src/main/java/fr/openmc/core/features/homes/command/RenameHomeCommand.java +++ b/src/main/java/fr/openmc/core/features/homes/command/RenameHomeCommand.java @@ -4,9 +4,9 @@ import fr.openmc.core.features.homes.command.autocomplete.HomeAutoComplete; import fr.openmc.core.features.homes.models.Home; import fr.openmc.core.features.homes.utils.HomeUtil; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; diff --git a/src/main/java/fr/openmc/core/features/homes/command/SetHomeCommand.java b/src/main/java/fr/openmc/core/features/homes/command/SetHomeCommand.java index a73139130..c2b4694dd 100644 --- a/src/main/java/fr/openmc/core/features/homes/command/SetHomeCommand.java +++ b/src/main/java/fr/openmc/core/features/homes/command/SetHomeCommand.java @@ -8,9 +8,9 @@ import fr.openmc.core.features.homes.models.Home; import fr.openmc.core.features.homes.utils.HomeUtil; import fr.openmc.core.features.homes.world.DisabledWorldHome; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; diff --git a/src/main/java/fr/openmc/core/features/homes/command/TpHomeCommand.java b/src/main/java/fr/openmc/core/features/homes/command/TpHomeCommand.java index 93705d0fe..82d55d1d7 100644 --- a/src/main/java/fr/openmc/core/features/homes/command/TpHomeCommand.java +++ b/src/main/java/fr/openmc/core/features/homes/command/TpHomeCommand.java @@ -7,10 +7,10 @@ import fr.openmc.core.features.homes.events.HomeTpEvent; import fr.openmc.core.features.homes.menu.HomeMenu; import fr.openmc.core.features.homes.models.Home; -import fr.openmc.core.utils.PlayerUtils; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.bukkit.PlayerUtils; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; diff --git a/src/main/java/fr/openmc/core/features/homes/icons/CachedIconItem.java b/src/main/java/fr/openmc/core/features/homes/icons/CachedIconItem.java index c3a7bb22a..0618d4828 100644 --- a/src/main/java/fr/openmc/core/features/homes/icons/CachedIconItem.java +++ b/src/main/java/fr/openmc/core/features/homes/icons/CachedIconItem.java @@ -5,9 +5,9 @@ import fr.openmc.core.OMCPlugin; import fr.openmc.core.features.homes.menu.HomeChangeIconMenu; import fr.openmc.core.features.homes.models.Home; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import io.papermc.paper.datacomponent.DataComponentTypes; import io.papermc.paper.datacomponent.item.TooltipDisplay; import lombok.Getter; 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 e2caeb34a..9c83f7667 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,6 +1,8 @@ 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.features.homes.menu.HomeChangeIconMenu; import fr.openmc.core.features.homes.models.Home; import org.bukkit.Bukkit; @@ -11,7 +13,7 @@ import java.util.List; import java.util.concurrent.ConcurrentHashMap; -public class HomeIconCacheManager { +public class HomeIconCacheManager extends Feature implements LoadAfterItemsAdder { private static final ConcurrentHashMap> CACHED_ITEMS = new ConcurrentHashMap<>(); private static final ConcurrentHashMap> CACHED_SEARCH_RESULTS = new ConcurrentHashMap<>(); @@ -20,6 +22,16 @@ public class HomeIconCacheManager { private static final Integer MAX_CACHE_SIZE = 50; + @Override + public void init() { + HomeIconCacheManager.initialize(); + } + + @Override + public void save() { + HomeIconCacheManager.clearCache(); + } + /** * Initializes the HomeIconCacheManager and preloads all icons into the cache. * This method should be called once at the start of the plugin. diff --git a/src/main/java/fr/openmc/core/features/homes/menu/HomeChangeIconMenu.java b/src/main/java/fr/openmc/core/features/homes/menu/HomeChangeIconMenu.java index 541b8ad65..01214fa80 100644 --- a/src/main/java/fr/openmc/core/features/homes/menu/HomeChangeIconMenu.java +++ b/src/main/java/fr/openmc/core/features/homes/menu/HomeChangeIconMenu.java @@ -1,7 +1,7 @@ package fr.openmc.core.features.homes.menu; import dev.lone.itemsadder.api.FontImages.FontImageWrapper; -import fr.openmc.api.input.DialogInput; +import fr.openmc.api.input.dialog.DialogInput; import fr.openmc.api.menulib.PaginatedMenu; import fr.openmc.api.menulib.utils.InventorySize; import fr.openmc.api.menulib.utils.ItemBuilder; @@ -11,10 +11,10 @@ import fr.openmc.core.features.homes.models.Home; import fr.openmc.core.features.mailboxes.utils.MailboxMenuManager; import fr.openmc.core.registry.items.CustomItemRegistry; -import fr.openmc.core.utils.ItemUtils; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.bukkit.ItemUtils; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; import org.bukkit.Bukkit; @@ -30,7 +30,7 @@ import java.util.*; import java.util.concurrent.ConcurrentHashMap; -import static fr.openmc.core.utils.InputUtils.MAX_LENGTH; +import static fr.openmc.core.utils.text.InputUtils.MAX_LENGTH; public class HomeChangeIconMenu extends PaginatedMenu { diff --git a/src/main/java/fr/openmc/core/features/homes/menu/HomeConfigMenu.java b/src/main/java/fr/openmc/core/features/homes/menu/HomeConfigMenu.java index fbaf7045a..c09e5492c 100644 --- a/src/main/java/fr/openmc/core/features/homes/menu/HomeConfigMenu.java +++ b/src/main/java/fr/openmc/core/features/homes/menu/HomeConfigMenu.java @@ -1,7 +1,7 @@ package fr.openmc.core.features.homes.menu; import dev.lone.itemsadder.api.FontImages.FontImageWrapper; -import fr.openmc.api.input.DialogInput; +import fr.openmc.api.input.dialog.DialogInput; import fr.openmc.api.menulib.Menu; import fr.openmc.api.menulib.utils.InventorySize; import fr.openmc.api.menulib.utils.ItemBuilder; @@ -11,10 +11,10 @@ import fr.openmc.core.features.homes.utils.HomeUtil; import fr.openmc.core.features.mailboxes.utils.MailboxMenuManager; import fr.openmc.core.registry.items.CustomItemRegistry; -import fr.openmc.core.utils.customfonts.CustomFonts; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.fonts.CustomFonts; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.TextComponent; import net.kyori.adventure.text.format.NamedTextColor; diff --git a/src/main/java/fr/openmc/core/features/homes/menu/HomeDeleteConfirmMenu.java b/src/main/java/fr/openmc/core/features/homes/menu/HomeDeleteConfirmMenu.java index 22e99421e..9aeef5c13 100644 --- a/src/main/java/fr/openmc/core/features/homes/menu/HomeDeleteConfirmMenu.java +++ b/src/main/java/fr/openmc/core/features/homes/menu/HomeDeleteConfirmMenu.java @@ -8,9 +8,9 @@ import fr.openmc.core.features.homes.HomesManager; import fr.openmc.core.features.homes.models.Home; import fr.openmc.core.registry.items.CustomItemRegistry; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.entity.Player; import org.bukkit.event.inventory.InventoryClickEvent; diff --git a/src/main/java/fr/openmc/core/features/homes/menu/HomeMenu.java b/src/main/java/fr/openmc/core/features/homes/menu/HomeMenu.java index 6ff69e818..61fd67f2b 100644 --- a/src/main/java/fr/openmc/core/features/homes/menu/HomeMenu.java +++ b/src/main/java/fr/openmc/core/features/homes/menu/HomeMenu.java @@ -13,9 +13,9 @@ import fr.openmc.core.features.homes.models.Home; import fr.openmc.core.features.mailboxes.utils.MailboxMenuManager; import fr.openmc.core.registry.items.CustomItemRegistry; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.Bukkit; import org.bukkit.Material; 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 6ac6e32fc..7c32c88bb 100644 --- a/src/main/java/fr/openmc/core/features/leaderboards/LeaderboardManager.java +++ b/src/main/java/fr/openmc/core/features/leaderboards/LeaderboardManager.java @@ -2,6 +2,9 @@ import fr.openmc.core.CommandsManager; 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.features.types.NotInUnitTest; import fr.openmc.core.features.city.City; import fr.openmc.core.features.city.CityManager; import fr.openmc.core.features.economy.BankManager; @@ -10,8 +13,8 @@ import fr.openmc.core.features.events.contents.halloween.managers.HalloweenManager; import fr.openmc.core.features.events.contents.halloween.models.HalloweenData; import fr.openmc.core.features.leaderboards.commands.LeaderboardCommands; -import fr.openmc.core.utils.DateUtils; -import fr.openmc.core.utils.entities.TextDisplay; +import fr.openmc.core.utils.text.DateUtils; +import fr.openmc.core.utils.world.entities.TextDisplay; import it.unimi.dsi.fastutil.objects.Object2ObjectMap; import lombok.Getter; import net.kyori.adventure.text.Component; @@ -38,7 +41,7 @@ import java.net.URI; import java.util.*; -public class LeaderboardManager { +public class LeaderboardManager extends Feature implements NotInUnitTest, LoadAfterItemsAdder { @Getter private static final Map> githubContributorsMap = new TreeMap<>(); @Getter @@ -49,7 +52,7 @@ public class LeaderboardManager { private static final Map> playTimeMap = new TreeMap<>(); @Getter private static final Map> pumpkinCountMap = new TreeMap<>(); - private static final File leaderBoardFile = new File(OMCPlugin.getInstance().getDataFolder() + "/data", "leaderboards.yml"); + private static File leaderBoardFile; @Getter private static Location contributorsHologramLocation; @Getter @@ -68,12 +71,29 @@ public class LeaderboardManager { private static TextDisplay playTimeHologram; private static TextDisplay pumpkinCountHologram; - public static void init() { + private static File getLeaderBoardFile() { + if (leaderBoardFile == null) { + OMCPlugin plugin = OMCPlugin.getInstance(); + if (plugin == null) { + throw new IllegalStateException("OMCPlugin instance not initialized"); + } + leaderBoardFile = new File(plugin.getDataFolder(), "data/leaderboards.yml"); + } + return leaderBoardFile; + } + + @Override + public void init() { loadLeaderBoardConfig(); CommandsManager.getHandler().register(new LeaderboardCommands()); enable(); } + @Override + public void save() { + // nothing to save + } + /** * Creates the leaderboard text for GitHub contributors to be sent in chat or displayed as a hologram. * @@ -319,6 +339,7 @@ public static void disable() { * @throws IOException If an error occurs while saving the configuration. */ public static void setHologramLocation(String name, Location location) throws IOException { + File leaderBoardFile = getLeaderBoardFile(); FileConfiguration leaderBoardConfig = YamlConfiguration.loadConfiguration(leaderBoardFile); leaderBoardConfig.set(name + "-location", location); leaderBoardConfig.save(leaderBoardFile); @@ -343,6 +364,7 @@ public static void setHologramLocation(String name, Location location) throws IO * @throws IOException If an error occurs while saving the configuration. */ public static void setScale(float scale) throws IOException { + File leaderBoardFile = getLeaderBoardFile(); FileConfiguration leaderBoardConfig = YamlConfiguration.loadConfiguration(leaderBoardFile); leaderBoardConfig.set("scale", scale); leaderBoardConfig.save(leaderBoardFile); @@ -368,6 +390,7 @@ public static void setScale(float scale) throws IOException { * Loads the leaderboard configuration, including hologram locations. */ private static void loadLeaderBoardConfig() { + File leaderBoardFile = getLeaderBoardFile(); if (!leaderBoardFile.exists()) { leaderBoardFile.getParentFile().mkdirs(); OMCPlugin.getInstance().saveResource("data/leaderboards.yml", false); diff --git a/src/main/java/fr/openmc/core/features/leaderboards/commands/LeaderboardCommands.java b/src/main/java/fr/openmc/core/features/leaderboards/commands/LeaderboardCommands.java index 78b27142c..f3bfc1e58 100644 --- a/src/main/java/fr/openmc/core/features/leaderboards/commands/LeaderboardCommands.java +++ b/src/main/java/fr/openmc/core/features/leaderboards/commands/LeaderboardCommands.java @@ -1,9 +1,9 @@ package fr.openmc.core.features.leaderboards.commands; import fr.openmc.core.features.leaderboards.LeaderboardManager; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; diff --git a/src/main/java/fr/openmc/core/features/mailboxes/Letter.java b/src/main/java/fr/openmc/core/features/mailboxes/Letter.java index 7c08d21ad..f789f1c9d 100644 --- a/src/main/java/fr/openmc/core/features/mailboxes/Letter.java +++ b/src/main/java/fr/openmc/core/features/mailboxes/Letter.java @@ -7,8 +7,8 @@ import fr.openmc.api.menulib.utils.ItemBuilder; import fr.openmc.core.features.mailboxes.letter.LetterHead; import fr.openmc.core.features.mailboxes.letter.SenderLetter; +import fr.openmc.core.utils.bukkit.serializer.BukkitSerializer; import fr.openmc.core.utils.cache.CacheOfflinePlayer; -import fr.openmc.core.utils.serializer.BukkitSerializer; import lombok.Getter; import org.bukkit.OfflinePlayer; import org.bukkit.inventory.ItemStack; diff --git a/src/main/java/fr/openmc/core/features/mailboxes/MailboxCommand.java b/src/main/java/fr/openmc/core/features/mailboxes/MailboxCommand.java index 26feda8b0..c6ee42e56 100644 --- a/src/main/java/fr/openmc/core/features/mailboxes/MailboxCommand.java +++ b/src/main/java/fr/openmc/core/features/mailboxes/MailboxCommand.java @@ -1,16 +1,15 @@ package fr.openmc.core.features.mailboxes; import fr.openmc.core.commands.autocomplete.OnlinePlayerAutoComplete; -import fr.openmc.core.features.mailboxes.letter.LetterHead; import fr.openmc.core.features.mailboxes.menu.HomeMailbox; import fr.openmc.core.features.mailboxes.menu.PendingMailbox; import fr.openmc.core.features.mailboxes.menu.PlayerMailbox; import fr.openmc.core.features.mailboxes.menu.letter.LetterMenu; import fr.openmc.core.features.mailboxes.menu.letter.SendingLetter; import fr.openmc.core.features.mailboxes.utils.MailboxMenuManager; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; import org.bukkit.Bukkit; 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 464262f76..c28cfb463 100644 --- a/src/main/java/fr/openmc/core/features/mailboxes/MailboxManager.java +++ b/src/main/java/fr/openmc/core/features/mailboxes/MailboxManager.java @@ -5,15 +5,17 @@ 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.DatabaseFeature; 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.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; -import fr.openmc.core.utils.serializer.BukkitSerializer; +import fr.openmc.core.utils.bukkit.serializer.BukkitSerializer; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.event.ClickEvent; import net.kyori.adventure.text.format.NamedTextColor; @@ -33,14 +35,24 @@ import java.util.*; import static fr.openmc.core.features.mailboxes.utils.MailboxUtils.getHoverEvent; -import static fr.openmc.core.utils.InputUtils.pluralize; +import static fr.openmc.core.utils.text.InputUtils.pluralize; -public class MailboxManager { +public class MailboxManager extends Feature implements DatabaseFeature { private static final int MAX_STACKS_PER_LETTER = 27; private static final List letters = new ArrayList<>(); private static int nextLetterId = 1; + @Override + public void init() { + MailboxManager.loadLetters(); + } + + @Override + public void save() { + MailboxManager.saveLetters(); + } + public static boolean sendItems(Player sender, OfflinePlayer receiver, ItemStack[] items) { if (!canSend(sender, receiver)) return false; @@ -245,7 +257,8 @@ public static void cancelLetter(Player player) { private static Dao letterDao; - public static void initDB(ConnectionSource connectionSource) throws SQLException { + @Override + public void initDB(ConnectionSource connectionSource) throws SQLException { TableUtils.createTableIfNotExists(connectionSource, Letter.class); letterDao = DaoManager.createDao(connectionSource, Letter.class); } diff --git a/src/main/java/fr/openmc/core/features/mailboxes/letter/LetterHead.java b/src/main/java/fr/openmc/core/features/mailboxes/letter/LetterHead.java index 8389c33db..2bde9a920 100644 --- a/src/main/java/fr/openmc/core/features/mailboxes/letter/LetterHead.java +++ b/src/main/java/fr/openmc/core/features/mailboxes/letter/LetterHead.java @@ -10,15 +10,14 @@ import org.bukkit.OfflinePlayer; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.SkullMeta; -import org.jetbrains.annotations.ApiStatus; import java.time.LocalDateTime; import java.util.List; import static fr.openmc.core.features.mailboxes.utils.MailboxUtils.getPlayerName; import static fr.openmc.core.features.mailboxes.utils.MailboxUtils.nonItalic; -import static fr.openmc.core.utils.DateUtils.formatRelativeDate; -import static fr.openmc.core.utils.InputUtils.pluralize; +import static fr.openmc.core.utils.text.DateUtils.formatRelativeDate; +import static fr.openmc.core.utils.text.InputUtils.pluralize; @Getter @SuppressWarnings("UnstableApiUsage") diff --git a/src/main/java/fr/openmc/core/features/mailboxes/letter/SenderLetter.java b/src/main/java/fr/openmc/core/features/mailboxes/letter/SenderLetter.java index 9921c2922..243e71ed2 100644 --- a/src/main/java/fr/openmc/core/features/mailboxes/letter/SenderLetter.java +++ b/src/main/java/fr/openmc/core/features/mailboxes/letter/SenderLetter.java @@ -12,8 +12,8 @@ import java.util.ArrayList; import static fr.openmc.core.features.mailboxes.utils.MailboxUtils.*; -import static fr.openmc.core.utils.DateUtils.formatRelativeDate; -import static fr.openmc.core.utils.InputUtils.pluralize; +import static fr.openmc.core.utils.text.DateUtils.formatRelativeDate; +import static fr.openmc.core.utils.text.InputUtils.pluralize; @Getter public class SenderLetter extends ItemStack { diff --git a/src/main/java/fr/openmc/core/features/mailboxes/menu/PendingMailbox.java b/src/main/java/fr/openmc/core/features/mailboxes/menu/PendingMailbox.java index 8fa949e5f..a271a86ed 100644 --- a/src/main/java/fr/openmc/core/features/mailboxes/menu/PendingMailbox.java +++ b/src/main/java/fr/openmc/core/features/mailboxes/menu/PendingMailbox.java @@ -8,11 +8,11 @@ import fr.openmc.core.features.mailboxes.Letter; import fr.openmc.core.features.mailboxes.MailboxManager; import fr.openmc.core.features.mailboxes.utils.MailboxMenuManager; +import fr.openmc.core.utils.bukkit.serializer.BukkitSerializer; import fr.openmc.core.utils.cache.CacheOfflinePlayer; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; -import fr.openmc.core.utils.serializer.BukkitSerializer; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; import org.bukkit.Material; @@ -28,7 +28,7 @@ import java.util.List; import java.util.Map; -import static fr.openmc.core.utils.InputUtils.pluralize; +import static fr.openmc.core.utils.text.InputUtils.pluralize; public class PendingMailbox extends PaginatedMenu { public PendingMailbox(Player player) { diff --git a/src/main/java/fr/openmc/core/features/mailboxes/menu/PlayersList.java b/src/main/java/fr/openmc/core/features/mailboxes/menu/PlayersList.java index 899aaa997..7aaca0d0b 100644 --- a/src/main/java/fr/openmc/core/features/mailboxes/menu/PlayersList.java +++ b/src/main/java/fr/openmc/core/features/mailboxes/menu/PlayersList.java @@ -9,7 +9,7 @@ import fr.openmc.core.features.mailboxes.MailboxManager; import fr.openmc.core.features.mailboxes.menu.letter.SendingLetter; import fr.openmc.core.features.mailboxes.utils.MailboxMenuManager; -import fr.openmc.core.utils.ItemUtils; +import fr.openmc.core.utils.bukkit.ItemUtils; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/src/main/java/fr/openmc/core/features/mailboxes/menu/letter/LetterMenu.java b/src/main/java/fr/openmc/core/features/mailboxes/menu/letter/LetterMenu.java index 112c42258..a6c77f83e 100644 --- a/src/main/java/fr/openmc/core/features/mailboxes/menu/letter/LetterMenu.java +++ b/src/main/java/fr/openmc/core/features/mailboxes/menu/letter/LetterMenu.java @@ -10,12 +10,11 @@ import fr.openmc.core.features.mailboxes.events.ClaimLetterEvent; import fr.openmc.core.features.mailboxes.letter.LetterHead; import fr.openmc.core.features.mailboxes.utils.MailboxMenuManager; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; -import fr.openmc.core.utils.serializer.BukkitSerializer; +import fr.openmc.core.utils.bukkit.serializer.BukkitSerializer; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; -import net.kyori.adventure.text.event.ClickEvent; import net.kyori.adventure.text.format.NamedTextColor; import org.bukkit.Bukkit; import org.bukkit.World; @@ -30,7 +29,7 @@ import java.util.Map; import static fr.openmc.core.features.mailboxes.utils.MailboxMenuManager.*; -import static fr.openmc.core.utils.InputUtils.pluralize; +import static fr.openmc.core.utils.text.InputUtils.pluralize; public class LetterMenu extends Menu { private final Letter letter; diff --git a/src/main/java/fr/openmc/core/features/mailboxes/menu/letter/SendingLetter.java b/src/main/java/fr/openmc/core/features/mailboxes/menu/letter/SendingLetter.java index 571addc84..67483f8ea 100644 --- a/src/main/java/fr/openmc/core/features/mailboxes/menu/letter/SendingLetter.java +++ b/src/main/java/fr/openmc/core/features/mailboxes/menu/letter/SendingLetter.java @@ -1,6 +1,5 @@ package fr.openmc.core.features.mailboxes.menu.letter; -import com.j256.ormlite.stmt.query.In; import dev.lone.itemsadder.api.FontImages.FontImageWrapper; import fr.openmc.api.menulib.Menu; import fr.openmc.api.menulib.utils.InventorySize; @@ -9,10 +8,10 @@ import fr.openmc.core.OMCPlugin; import fr.openmc.core.features.mailboxes.MailboxManager; import fr.openmc.core.features.mailboxes.utils.MailboxMenuManager; -import fr.openmc.core.utils.ItemUtils; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.bukkit.ItemUtils; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; import org.bukkit.Bukkit; @@ -24,7 +23,10 @@ import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import java.util.stream.IntStream; import java.util.stream.Stream; diff --git a/src/main/java/fr/openmc/core/features/mailboxes/utils/MailboxMenuManager.java b/src/main/java/fr/openmc/core/features/mailboxes/utils/MailboxMenuManager.java index cd2ca3cd2..5bb6f9cd8 100644 --- a/src/main/java/fr/openmc/core/features/mailboxes/utils/MailboxMenuManager.java +++ b/src/main/java/fr/openmc/core/features/mailboxes/utils/MailboxMenuManager.java @@ -7,9 +7,9 @@ import fr.openmc.core.features.mailboxes.menu.HomeMailbox; import fr.openmc.core.features.mailboxes.menu.PendingMailbox; import fr.openmc.core.registry.items.CustomItemRegistry; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.TextDecoration; 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 898aba1bb..2f46b3774 100644 --- a/src/main/java/fr/openmc/core/features/mainmenu/MainMenu.java +++ b/src/main/java/fr/openmc/core/features/mainmenu/MainMenu.java @@ -2,16 +2,25 @@ import fr.openmc.api.packetmenulib.PacketMenuLib; 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.features.types.NotInUnitTest; import fr.openmc.core.features.mainmenu.listeners.PacketListener; import fr.openmc.core.features.mainmenu.menus.Page1; import org.bukkit.entity.Player; -public class MainMenu { - public static void init(OMCPlugin plugin) { - new PacketListener(plugin); +public class MainMenu extends Feature implements NotInUnitTest, LoadAfterItemsAdder { + @Override + public void init() { + new PacketListener(OMCPlugin.getInstance()); } public static void openMainMenu(Player player) { PacketMenuLib.openMenu(new Page1(player), player); } + + @Override + public void save() { + //nothing to save + } } 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 1b7e92aa8..8bec53f8d 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 @@ -26,10 +26,10 @@ import fr.openmc.core.features.milestones.menus.MainMilestonesMenu; import fr.openmc.core.features.quests.command.QuestCommand; import fr.openmc.core.features.settings.command.SettingsCommand; -import fr.openmc.core.utils.DateUtils; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.DateUtils; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.TextDecoration; diff --git a/src/main/java/fr/openmc/core/features/mainmenu/menus/Page2.java b/src/main/java/fr/openmc/core/features/mainmenu/menus/Page2.java index 6651adecd..23d60e52b 100644 --- a/src/main/java/fr/openmc/core/features/mainmenu/menus/Page2.java +++ b/src/main/java/fr/openmc/core/features/mainmenu/menus/Page2.java @@ -13,9 +13,9 @@ import fr.openmc.core.features.mailboxes.MailboxCommand; import fr.openmc.core.features.mainmenu.listeners.PacketListener; import fr.openmc.core.features.settings.command.SettingsCommand; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; import net.minecraft.network.protocol.game.ClientboundUpdateAdvancementsPacket; 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 fe9bc5672..5b22ecaa5 100644 --- a/src/main/java/fr/openmc/core/features/milestones/MilestonesManager.java +++ b/src/main/java/fr/openmc/core/features/milestones/MilestonesManager.java @@ -6,6 +6,9 @@ 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.DatabaseFeature; +import fr.openmc.core.bootstrap.features.types.LoadAfterItemsAdder; import fr.openmc.core.features.milestones.listeners.PlayerJoin; import fr.openmc.core.features.milestones.tutorial.listeners.TutorialBossBarEvent; import fr.openmc.core.features.quests.objects.Quest; @@ -15,12 +18,13 @@ import java.sql.SQLException; import java.util.*; -public class MilestonesManager { +public class MilestonesManager extends Feature implements DatabaseFeature, LoadAfterItemsAdder { private static final Set milestones = new HashSet<>(); private static Dao millestoneDao; - public static void init() { + @Override + public void init() { Arrays.stream(MilestoneType.values()).toList().forEach(milestoneType -> registerMilestone(milestoneType.getMilestone())); loadMilestonesData(); @@ -34,12 +38,18 @@ public static void init() { ); } + @Override + public void save() { + MilestonesManager.saveMilestonesData(); + } + /** * Initialize the database for milestones. * * @param connectionSource the connection source to the database */ - public static void initDB(ConnectionSource connectionSource) throws SQLException { + @Override + public void initDB(ConnectionSource connectionSource) throws SQLException { TableUtils.createTableIfNotExists(connectionSource, MilestoneModel.class); millestoneDao = DaoManager.createDao(connectionSource, MilestoneModel.class); } diff --git a/src/main/java/fr/openmc/core/features/milestones/tutorial/TutorialHologram.java b/src/main/java/fr/openmc/core/features/milestones/tutorial/TutorialHologram.java index c10041c63..e5ce699da 100644 --- a/src/main/java/fr/openmc/core/features/milestones/tutorial/TutorialHologram.java +++ b/src/main/java/fr/openmc/core/features/milestones/tutorial/TutorialHologram.java @@ -1,7 +1,7 @@ package fr.openmc.core.features.milestones.tutorial; -import dev.lone.itemsadder.api.FontImages.FontImageWrapper; import fr.openmc.core.features.displays.holograms.Hologram; +import fr.openmc.core.utils.text.fonts.CustomFonts; public class TutorialHologram extends Hologram { @@ -9,7 +9,7 @@ public TutorialHologram() { super("tutorial"); this.setLines( - "§f" + new FontImageWrapper("omc_icons:openmc").getString(), + "§f" + CustomFonts.getBest("omc_icons:openmc", "§f"), "§fBienvenue sur §dOpenMC V2§f!", "§fCette version est basée sur les §2villes", "§f", diff --git a/src/main/java/fr/openmc/core/features/milestones/tutorial/quests/BreakAyweniteQuest.java b/src/main/java/fr/openmc/core/features/milestones/tutorial/quests/BreakAyweniteQuest.java index db0e67e76..5c1f11ccf 100644 --- a/src/main/java/fr/openmc/core/features/milestones/tutorial/quests/BreakAyweniteQuest.java +++ b/src/main/java/fr/openmc/core/features/milestones/tutorial/quests/BreakAyweniteQuest.java @@ -13,8 +13,8 @@ import fr.openmc.core.features.quests.rewards.QuestMoneyReward; import fr.openmc.core.features.quests.rewards.QuestTextReward; import fr.openmc.core.registry.items.CustomItemRegistry; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; diff --git a/src/main/java/fr/openmc/core/features/milestones/tutorial/quests/CityCreateQuest.java b/src/main/java/fr/openmc/core/features/milestones/tutorial/quests/CityCreateQuest.java index bdaf28170..f2c3f30dc 100644 --- a/src/main/java/fr/openmc/core/features/milestones/tutorial/quests/CityCreateQuest.java +++ b/src/main/java/fr/openmc/core/features/milestones/tutorial/quests/CityCreateQuest.java @@ -12,8 +12,8 @@ import fr.openmc.core.features.quests.rewards.QuestMethodsReward; import fr.openmc.core.features.quests.rewards.QuestMoneyReward; import fr.openmc.core.features.quests.rewards.QuestTextReward; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.Prefix; import org.bukkit.Material; import org.bukkit.OfflinePlayer; import org.bukkit.entity.Player; diff --git a/src/main/java/fr/openmc/core/features/milestones/tutorial/quests/CityLevelTwoQuest.java b/src/main/java/fr/openmc/core/features/milestones/tutorial/quests/CityLevelTwoQuest.java index 1653f9491..56e0310a7 100644 --- a/src/main/java/fr/openmc/core/features/milestones/tutorial/quests/CityLevelTwoQuest.java +++ b/src/main/java/fr/openmc/core/features/milestones/tutorial/quests/CityLevelTwoQuest.java @@ -9,8 +9,8 @@ import fr.openmc.core.features.quests.objects.QuestTier; import fr.openmc.core.features.quests.rewards.QuestMoneyReward; import fr.openmc.core.features.quests.rewards.QuestTextReward; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.Prefix; import org.bukkit.Material; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; diff --git a/src/main/java/fr/openmc/core/features/milestones/tutorial/quests/ClaimLetterQuest.java b/src/main/java/fr/openmc/core/features/milestones/tutorial/quests/ClaimLetterQuest.java index 897975c47..7660794a2 100644 --- a/src/main/java/fr/openmc/core/features/milestones/tutorial/quests/ClaimLetterQuest.java +++ b/src/main/java/fr/openmc/core/features/milestones/tutorial/quests/ClaimLetterQuest.java @@ -8,8 +8,8 @@ import fr.openmc.core.features.quests.objects.QuestTier; import fr.openmc.core.features.quests.rewards.QuestMoneyReward; import fr.openmc.core.features.quests.rewards.QuestTextReward; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.Prefix; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; diff --git a/src/main/java/fr/openmc/core/features/milestones/tutorial/quests/FinishQuestQuest.java b/src/main/java/fr/openmc/core/features/milestones/tutorial/quests/FinishQuestQuest.java index 466d37078..7c162fefa 100644 --- a/src/main/java/fr/openmc/core/features/milestones/tutorial/quests/FinishQuestQuest.java +++ b/src/main/java/fr/openmc/core/features/milestones/tutorial/quests/FinishQuestQuest.java @@ -8,8 +8,8 @@ import fr.openmc.core.features.quests.objects.QuestTier; import fr.openmc.core.features.quests.rewards.QuestMoneyReward; import fr.openmc.core.features.quests.rewards.QuestTextReward; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.Prefix; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; diff --git a/src/main/java/fr/openmc/core/features/milestones/tutorial/quests/HomeCreateQuest.java b/src/main/java/fr/openmc/core/features/milestones/tutorial/quests/HomeCreateQuest.java index e513ee090..7a35df9fd 100644 --- a/src/main/java/fr/openmc/core/features/milestones/tutorial/quests/HomeCreateQuest.java +++ b/src/main/java/fr/openmc/core/features/milestones/tutorial/quests/HomeCreateQuest.java @@ -11,8 +11,8 @@ import fr.openmc.core.features.quests.rewards.QuestMoneyReward; import fr.openmc.core.features.quests.rewards.QuestTextReward; import fr.openmc.core.registry.items.CustomItemRegistry; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.Prefix; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; diff --git a/src/main/java/fr/openmc/core/features/milestones/tutorial/quests/HomeUpgradeQuest.java b/src/main/java/fr/openmc/core/features/milestones/tutorial/quests/HomeUpgradeQuest.java index f0c0bbe20..4048a953e 100644 --- a/src/main/java/fr/openmc/core/features/milestones/tutorial/quests/HomeUpgradeQuest.java +++ b/src/main/java/fr/openmc/core/features/milestones/tutorial/quests/HomeUpgradeQuest.java @@ -9,8 +9,8 @@ import fr.openmc.core.features.quests.rewards.QuestMoneyReward; import fr.openmc.core.features.quests.rewards.QuestTextReward; import fr.openmc.core.registry.items.CustomItemRegistry; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.Prefix; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; diff --git a/src/main/java/fr/openmc/core/features/milestones/tutorial/quests/OpenAdminShopMenuQuest.java b/src/main/java/fr/openmc/core/features/milestones/tutorial/quests/OpenAdminShopMenuQuest.java index 8699da646..396a50b76 100644 --- a/src/main/java/fr/openmc/core/features/milestones/tutorial/quests/OpenAdminShopMenuQuest.java +++ b/src/main/java/fr/openmc/core/features/milestones/tutorial/quests/OpenAdminShopMenuQuest.java @@ -9,8 +9,8 @@ import fr.openmc.core.features.quests.objects.QuestTier; import fr.openmc.core.features.quests.rewards.QuestMoneyReward; import fr.openmc.core.features.quests.rewards.QuestTextReward; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.Prefix; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; diff --git a/src/main/java/fr/openmc/core/features/milestones/tutorial/quests/OpenContestMenuQuest.java b/src/main/java/fr/openmc/core/features/milestones/tutorial/quests/OpenContestMenuQuest.java index 73ca896ab..14f4bba7f 100644 --- a/src/main/java/fr/openmc/core/features/milestones/tutorial/quests/OpenContestMenuQuest.java +++ b/src/main/java/fr/openmc/core/features/milestones/tutorial/quests/OpenContestMenuQuest.java @@ -9,8 +9,8 @@ import fr.openmc.core.features.quests.rewards.QuestMoneyReward; import fr.openmc.core.features.quests.rewards.QuestTextReward; import fr.openmc.core.registry.items.CustomItemRegistry; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.Prefix; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; diff --git a/src/main/java/fr/openmc/core/features/milestones/tutorial/quests/OpenQuestMenuQuest.java b/src/main/java/fr/openmc/core/features/milestones/tutorial/quests/OpenQuestMenuQuest.java index 97bfa5d34..e5a45eda9 100644 --- a/src/main/java/fr/openmc/core/features/milestones/tutorial/quests/OpenQuestMenuQuest.java +++ b/src/main/java/fr/openmc/core/features/milestones/tutorial/quests/OpenQuestMenuQuest.java @@ -9,8 +9,8 @@ import fr.openmc.core.features.quests.objects.QuestTier; import fr.openmc.core.features.quests.rewards.QuestMoneyReward; import fr.openmc.core.features.quests.rewards.QuestTextReward; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.Prefix; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; diff --git a/src/main/java/fr/openmc/core/features/milestones/tutorial/quests/OpenSettingsMenuQuest.java b/src/main/java/fr/openmc/core/features/milestones/tutorial/quests/OpenSettingsMenuQuest.java index 1191abacc..7f59a29b1 100644 --- a/src/main/java/fr/openmc/core/features/milestones/tutorial/quests/OpenSettingsMenuQuest.java +++ b/src/main/java/fr/openmc/core/features/milestones/tutorial/quests/OpenSettingsMenuQuest.java @@ -9,8 +9,8 @@ import fr.openmc.core.features.quests.rewards.QuestMoneyReward; import fr.openmc.core.features.quests.rewards.QuestTextReward; import fr.openmc.core.features.settings.menu.PlayerSettingsMenu; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.Prefix; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; diff --git a/src/main/java/fr/openmc/core/features/milestones/tutorial/quests/SellBuyQuest.java b/src/main/java/fr/openmc/core/features/milestones/tutorial/quests/SellBuyQuest.java index f4cd24932..de293511e 100644 --- a/src/main/java/fr/openmc/core/features/milestones/tutorial/quests/SellBuyQuest.java +++ b/src/main/java/fr/openmc/core/features/milestones/tutorial/quests/SellBuyQuest.java @@ -10,8 +10,8 @@ import fr.openmc.core.features.quests.rewards.QuestMoneyReward; import fr.openmc.core.features.quests.rewards.QuestTextReward; import fr.openmc.core.listeners.PlayerDeathListener; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.Prefix; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; diff --git a/src/main/java/fr/openmc/core/features/milestones/tutorial/quests/SpareBankQuest.java b/src/main/java/fr/openmc/core/features/milestones/tutorial/quests/SpareBankQuest.java index 9ddd4339f..0368926b9 100644 --- a/src/main/java/fr/openmc/core/features/milestones/tutorial/quests/SpareBankQuest.java +++ b/src/main/java/fr/openmc/core/features/milestones/tutorial/quests/SpareBankQuest.java @@ -8,8 +8,8 @@ import fr.openmc.core.features.quests.objects.QuestTier; import fr.openmc.core.features.quests.rewards.QuestMoneyReward; import fr.openmc.core.features.quests.rewards.QuestTextReward; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.Prefix; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.entity.Player; 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 abd483953..a85437852 100644 --- a/src/main/java/fr/openmc/core/features/privatemessage/PrivateMessageManager.java +++ b/src/main/java/fr/openmc/core/features/privatemessage/PrivateMessageManager.java @@ -1,9 +1,9 @@ package fr.openmc.core.features.privatemessage; import fr.openmc.core.features.settings.PlayerSettingsManager; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.entity.Player; 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 495c9a273..8da20b82c 100644 --- a/src/main/java/fr/openmc/core/features/privatemessage/SocialSpyManager.java +++ b/src/main/java/fr/openmc/core/features/privatemessage/SocialSpyManager.java @@ -1,8 +1,8 @@ package fr.openmc.core.features.privatemessage; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.Bukkit; import org.bukkit.entity.Player; diff --git a/src/main/java/fr/openmc/core/features/privatemessage/command/SocialSpyCommand.java b/src/main/java/fr/openmc/core/features/privatemessage/command/SocialSpyCommand.java index 735a0ec5c..2daafd300 100644 --- a/src/main/java/fr/openmc/core/features/privatemessage/command/SocialSpyCommand.java +++ b/src/main/java/fr/openmc/core/features/privatemessage/command/SocialSpyCommand.java @@ -2,9 +2,9 @@ import fr.openmc.core.commands.autocomplete.OnlinePlayerAutoComplete; import fr.openmc.core.features.privatemessage.SocialSpyManager; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.Bukkit; import org.bukkit.entity.Player; 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 3ece62f0d..766321d22 100644 --- a/src/main/java/fr/openmc/core/features/quests/QuestsManager.java +++ b/src/main/java/fr/openmc/core/features/quests/QuestsManager.java @@ -1,6 +1,8 @@ package fr.openmc.core.features.quests; import fr.openmc.core.OMCPlugin; +import fr.openmc.core.bootstrap.features.Feature; +import fr.openmc.core.bootstrap.features.types.LoadAfterItemsAdder; import fr.openmc.core.features.quests.objects.Quest; import fr.openmc.core.features.quests.quests.*; import org.bukkit.Bukkit; @@ -17,7 +19,7 @@ * It handles the registration of quests, loading default quests, * and saving quest progress for players. */ -public class QuestsManager { +public class QuestsManager extends Feature implements LoadAfterItemsAdder { static final Map quests = new HashMap<>(); /** @@ -25,11 +27,19 @@ public class QuestsManager { * This constructor initializes the instance of QuestsManager, * loads default quests, and loads all quest progress. */ - public static void init() { + @Override + public void init() { + QuestProgressSaveManager.init(); + loadDefaultQuests(); QuestProgressSaveManager.loadAllQuestProgress(); } + @Override + public void save() { + QuestsManager.saveQuests(); + } + /** * Register a quest. * If the quest is already registered, it will not be registered again. diff --git a/src/main/java/fr/openmc/core/features/quests/command/QuestCommand.java b/src/main/java/fr/openmc/core/features/quests/command/QuestCommand.java index d073d7733..efcabcd59 100644 --- a/src/main/java/fr/openmc/core/features/quests/command/QuestCommand.java +++ b/src/main/java/fr/openmc/core/features/quests/command/QuestCommand.java @@ -2,9 +2,9 @@ import fr.openmc.core.commands.autocomplete.OnlinePlayerAutoComplete; import fr.openmc.core.features.quests.menus.QuestsMenu; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import org.bukkit.entity.Player; import revxrsal.commands.annotation.*; diff --git a/src/main/java/fr/openmc/core/features/quests/objects/Quest.java b/src/main/java/fr/openmc/core/features/quests/objects/Quest.java index e38f616cf..8e1863041 100644 --- a/src/main/java/fr/openmc/core/features/quests/objects/Quest.java +++ b/src/main/java/fr/openmc/core/features/quests/objects/Quest.java @@ -5,10 +5,10 @@ import fr.openmc.core.features.quests.events.QuestCompleteEvent; import fr.openmc.core.features.quests.rewards.QuestItemReward; import fr.openmc.core.features.quests.rewards.QuestReward; -import fr.openmc.core.utils.ItemUtils; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.bukkit.ItemUtils; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import lombok.Getter; import lombok.Setter; import net.kyori.adventure.text.Component; diff --git a/src/main/java/fr/openmc/core/features/quests/quests/BreakLogQuest.java b/src/main/java/fr/openmc/core/features/quests/quests/BreakLogQuest.java index 1334b7854..9e9eab8ad 100644 --- a/src/main/java/fr/openmc/core/features/quests/quests/BreakLogQuest.java +++ b/src/main/java/fr/openmc/core/features/quests/quests/BreakLogQuest.java @@ -4,7 +4,7 @@ import fr.openmc.core.features.quests.objects.QuestTier; import fr.openmc.core.features.quests.rewards.QuestItemReward; import fr.openmc.core.features.quests.rewards.QuestMoneyReward; -import fr.openmc.core.utils.ItemUtils; +import fr.openmc.core.utils.bukkit.ItemUtils; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.TextDecoration; diff --git a/src/main/java/fr/openmc/core/features/quests/quests/CraftTheMixtureQuest.java b/src/main/java/fr/openmc/core/features/quests/quests/CraftTheMixtureQuest.java index 8525143f9..0fed90267 100644 --- a/src/main/java/fr/openmc/core/features/quests/quests/CraftTheMixtureQuest.java +++ b/src/main/java/fr/openmc/core/features/quests/quests/CraftTheMixtureQuest.java @@ -5,7 +5,7 @@ import fr.openmc.core.features.quests.rewards.QuestItemReward; import fr.openmc.core.features.quests.rewards.QuestMoneyReward; import fr.openmc.core.registry.items.CustomItemRegistry; -import fr.openmc.core.utils.ItemUtils; +import fr.openmc.core.utils.bukkit.ItemUtils; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; diff --git a/src/main/java/fr/openmc/core/features/quests/rewards/QuestMoneyReward.java b/src/main/java/fr/openmc/core/features/quests/rewards/QuestMoneyReward.java index bc80c6831..97362bc4d 100644 --- a/src/main/java/fr/openmc/core/features/quests/rewards/QuestMoneyReward.java +++ b/src/main/java/fr/openmc/core/features/quests/rewards/QuestMoneyReward.java @@ -1,9 +1,9 @@ package fr.openmc.core.features.quests.rewards; import fr.openmc.core.features.economy.EconomyManager; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.entity.Player; diff --git a/src/main/java/fr/openmc/core/features/quests/rewards/QuestTextReward.java b/src/main/java/fr/openmc/core/features/quests/rewards/QuestTextReward.java index 1fd649e31..59bac4d97 100644 --- a/src/main/java/fr/openmc/core/features/quests/rewards/QuestTextReward.java +++ b/src/main/java/fr/openmc/core/features/quests/rewards/QuestTextReward.java @@ -1,9 +1,9 @@ package fr.openmc.core.features.quests.rewards; import fr.openmc.core.OMCPlugin; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.Bukkit; import org.bukkit.entity.Player; 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 0b48e61c0..9c91e6631 100644 --- a/src/main/java/fr/openmc/core/features/settings/PlayerSettingsManager.java +++ b/src/main/java/fr/openmc/core/features/settings/PlayerSettingsManager.java @@ -7,6 +7,8 @@ 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.DatabaseFeature; import fr.openmc.core.features.settings.models.PlayerSettingEntity; import lombok.Getter; import org.bukkit.entity.Player; @@ -23,18 +25,29 @@ import java.util.concurrent.ConcurrentHashMap; @Getter -public class PlayerSettingsManager implements Listener { +public class PlayerSettingsManager extends Feature implements Listener, DatabaseFeature { private static final Map playersSettings = new ConcurrentHashMap<>(); private static Dao playerSettingDao; + @Override + public void init() { + PlayerSettingsManager.loadAllPlayerSettings(); + } + + @Override + public void save() { + PlayerSettingsManager.saveAllSettings(); + } + /** * Initializes the database connection and creates tables if needed. * * @param connectionSource the database connection source * @throws SQLException if database initialization fails */ - public static void initDB(ConnectionSource connectionSource) throws SQLException { + @Override + public void initDB(ConnectionSource connectionSource) throws SQLException { playerSettingDao = DaoManager.createDao(connectionSource, PlayerSettingEntity.class); try { TableUtils.createTableIfNotExists(connectionSource, PlayerSettingEntity.class); diff --git a/src/main/java/fr/openmc/core/features/settings/menu/PlayerSettingsMenu.java b/src/main/java/fr/openmc/core/features/settings/menu/PlayerSettingsMenu.java index 3f45f0093..260db9d20 100644 --- a/src/main/java/fr/openmc/core/features/settings/menu/PlayerSettingsMenu.java +++ b/src/main/java/fr/openmc/core/features/settings/menu/PlayerSettingsMenu.java @@ -11,9 +11,9 @@ import fr.openmc.core.features.settings.SettingType; import fr.openmc.core.features.settings.policy.Policy; import fr.openmc.core.registry.items.CustomItemRegistry; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.TextDecoration; 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 9dc2de51a..1670ab11c 100644 --- a/src/main/java/fr/openmc/core/features/tickets/TicketManager.java +++ b/src/main/java/fr/openmc/core/features/tickets/TicketManager.java @@ -5,6 +5,7 @@ import com.google.gson.JsonObject; import com.google.gson.JsonParser; import fr.openmc.core.OMCPlugin; +import fr.openmc.core.bootstrap.features.Feature; import lombok.Getter; import lombok.Setter; @@ -15,7 +16,7 @@ import java.util.*; @Getter -public class TicketManager { +public class TicketManager extends Feature { public static int hoursPerTicket = 8; public static final List timePlayed = new ArrayList<>(); @@ -23,14 +24,26 @@ public class TicketManager { private static final Gson gson = new Gson(); @Setter private static File statsDirectory; + public TicketManager(File statsDirectory) { + TicketManager.setStatsDirectory(statsDirectory); + } + + @Override + public void init() { + TicketManager.loadPlayerStats(statsDirectory); + } + + @Override + public void save() { + // nothing to save + } + /** * Load player statistics from JSON files in the specified directory. * * @param statsDirectory The {@link File} directory containing player stats JSON files. */ public static void loadPlayerStats(File statsDirectory) { - TicketManager.setStatsDirectory(statsDirectory); - if (!statsDirectory.exists() || !statsDirectory.isDirectory()) { OMCPlugin.getInstance().getSLF4JLogger().info("Stats directory does not exist or is not a directory."); return; diff --git a/src/main/java/fr/openmc/core/features/tickets/menus/MachineBallsMenu.java b/src/main/java/fr/openmc/core/features/tickets/menus/MachineBallsMenu.java index 79c3ae2f3..358030216 100644 --- a/src/main/java/fr/openmc/core/features/tickets/menus/MachineBallsMenu.java +++ b/src/main/java/fr/openmc/core/features/tickets/menus/MachineBallsMenu.java @@ -5,9 +5,9 @@ import fr.openmc.api.menulib.utils.ItemBuilder; import fr.openmc.core.features.tickets.PlayerStats; import fr.openmc.core.features.tickets.TicketManager; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.key.Key; import net.kyori.adventure.sound.Sound; import net.kyori.adventure.text.Component; diff --git a/src/main/java/fr/openmc/core/features/tickets/menus/MachineBallsOpenMenu.java b/src/main/java/fr/openmc/core/features/tickets/menus/MachineBallsOpenMenu.java index 8274215ba..eed7f99c7 100644 --- a/src/main/java/fr/openmc/core/features/tickets/menus/MachineBallsOpenMenu.java +++ b/src/main/java/fr/openmc/core/features/tickets/menus/MachineBallsOpenMenu.java @@ -7,9 +7,9 @@ import fr.openmc.core.features.tickets.PlayerStats; import fr.openmc.core.features.tickets.TicketManager; import fr.openmc.core.registry.items.CustomItemRegistry; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.key.Key; import net.kyori.adventure.sound.Sound; import net.kyori.adventure.text.Component; diff --git a/src/main/java/fr/openmc/core/features/tpa/TPAQueue.java b/src/main/java/fr/openmc/core/features/tpa/TPAQueue.java index 6c730739c..2dcfed1f1 100644 --- a/src/main/java/fr/openmc/core/features/tpa/TPAQueue.java +++ b/src/main/java/fr/openmc/core/features/tpa/TPAQueue.java @@ -1,13 +1,14 @@ package fr.openmc.core.features.tpa; import fr.openmc.core.CommandsManager; +import fr.openmc.core.bootstrap.features.Feature; 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.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.Bukkit; import org.bukkit.entity.Player; @@ -17,7 +18,7 @@ import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; -public class TPAQueue { +public class TPAQueue extends Feature { /** * Map to store teleport requests @@ -26,7 +27,8 @@ public class TPAQueue { private static final ConcurrentHashMap> tpaRequests = new ConcurrentHashMap<>(); private static final ConcurrentHashMap tpaRequestTime = new ConcurrentHashMap<>(); - public static void initCommand() { + @Override + public void init() { CommandsManager.getHandler().register( new TPAcceptCommand(), new TPACommand(), @@ -35,6 +37,11 @@ public static void initCommand() { ); } + @Override + public void save() { + // nothing to save + } + /** * Check if the player has a pending teleport request * @param target The player to check diff --git a/src/main/java/fr/openmc/core/features/tpa/commands/TPACancelCommand.java b/src/main/java/fr/openmc/core/features/tpa/commands/TPACancelCommand.java index 6e8481745..f4555458c 100644 --- a/src/main/java/fr/openmc/core/features/tpa/commands/TPACancelCommand.java +++ b/src/main/java/fr/openmc/core/features/tpa/commands/TPACancelCommand.java @@ -1,9 +1,9 @@ package fr.openmc.core.features.tpa.commands; import fr.openmc.core.features.tpa.TPAQueue; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.entity.Player; import revxrsal.commands.annotation.Command; diff --git a/src/main/java/fr/openmc/core/features/tpa/commands/TPACommand.java b/src/main/java/fr/openmc/core/features/tpa/commands/TPACommand.java index 462de44ba..53d2c9f04 100644 --- a/src/main/java/fr/openmc/core/features/tpa/commands/TPACommand.java +++ b/src/main/java/fr/openmc/core/features/tpa/commands/TPACommand.java @@ -3,9 +3,9 @@ import fr.openmc.core.OMCPlugin; import fr.openmc.core.commands.autocomplete.OnlinePlayerAutoComplete; import fr.openmc.core.features.tpa.TPAQueue; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.event.ClickEvent; import net.kyori.adventure.text.event.HoverEvent; diff --git a/src/main/java/fr/openmc/core/features/tpa/commands/TPADenyCommand.java b/src/main/java/fr/openmc/core/features/tpa/commands/TPADenyCommand.java index 46f751dab..4bb7d6be3 100644 --- a/src/main/java/fr/openmc/core/features/tpa/commands/TPADenyCommand.java +++ b/src/main/java/fr/openmc/core/features/tpa/commands/TPADenyCommand.java @@ -2,9 +2,9 @@ import fr.openmc.core.features.tpa.TPAQueue; import fr.openmc.core.features.tpa.commands.autocomplete.TpaPendingAutoComplete; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.entity.Player; import revxrsal.commands.annotation.Command; diff --git a/src/main/java/fr/openmc/core/features/tpa/commands/TPAcceptCommand.java b/src/main/java/fr/openmc/core/features/tpa/commands/TPAcceptCommand.java index 9b16c3357..f644e0c34 100644 --- a/src/main/java/fr/openmc/core/features/tpa/commands/TPAcceptCommand.java +++ b/src/main/java/fr/openmc/core/features/tpa/commands/TPAcceptCommand.java @@ -2,10 +2,10 @@ import fr.openmc.core.features.tpa.TPAQueue; import fr.openmc.core.features.tpa.commands.autocomplete.TpaPendingAutoComplete; -import fr.openmc.core.utils.PlayerUtils; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.bukkit.PlayerUtils; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import org.bukkit.Location; import org.bukkit.entity.Player; 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 7c8ec3d26..0d1d3ba80 100644 --- a/src/main/java/fr/openmc/core/features/updates/UpdateManager.java +++ b/src/main/java/fr/openmc/core/features/updates/UpdateManager.java @@ -1,6 +1,7 @@ package fr.openmc.core.features.updates; import fr.openmc.core.OMCPlugin; +import fr.openmc.core.bootstrap.features.Feature; import lombok.Getter; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.event.ClickEvent; @@ -8,11 +9,12 @@ import org.bukkit.entity.Player; import org.bukkit.scheduler.BukkitRunnable; -public class UpdateManager { +public class UpdateManager extends Feature { @Getter static Component message; - public static void init() { + @Override + public void init() { String version = OMCPlugin.getInstance().getPluginMeta().getVersion(); String milestoneUrl = "https://github.com/ServerOpenMC/PluginV2/releases/"; @@ -32,6 +34,11 @@ public void run() { }.runTaskTimer(OMCPlugin.getInstance(), 0, period); } + @Override + public void save() { + // nothing to save + } + public static void sendUpdateMessage(Player player) { player.sendMessage(message); } diff --git a/src/main/java/fr/openmc/core/listeners/ArmorListener.java b/src/main/java/fr/openmc/core/listeners/ArmorListener.java index a2a9788cc..cffc89ac9 100644 --- a/src/main/java/fr/openmc/core/listeners/ArmorListener.java +++ b/src/main/java/fr/openmc/core/listeners/ArmorListener.java @@ -2,7 +2,6 @@ import fr.openmc.core.OMCPlugin; import fr.openmc.core.events.ArmorEquipEvent; -import fr.openmc.core.utils.ArmorType; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -44,7 +43,7 @@ public final void onInventoryClick(final InventoryClickEvent event) { if (!event.getInventory().getType().equals(InventoryType.CRAFTING) && !event.getInventory().getType().equals(InventoryType.PLAYER)) return; - ArmorType newArmorType = ArmorType.match(shift ? event.getCurrentItem() : event.getCursor()); + ArmorEquipEvent.ArmorType newArmorType = ArmorEquipEvent.ArmorType.match(shift ? event.getCurrentItem() : event.getCursor()); if (!shift && newArmorType != null && event.getRawSlot() != newArmorType.getSlot()) return; @@ -82,14 +81,14 @@ public final void onInventoryClick(final InventoryClickEvent event) { ItemStack hotbarItem = event.getClickedInventory().getItem(event.getHotbarButton()); if (!isAirOrNull(hotbarItem)) { - newArmorType = ArmorType.match(hotbarItem); + newArmorType = ArmorEquipEvent.ArmorType.match(hotbarItem); newArmorPiece = oldArmorPiece; oldArmorPiece = event.getClickedInventory().getItem(event.getSlot()); } else { - newArmorType = ArmorType.match(!isAirOrNull(oldArmorPiece) ? oldArmorPiece : newArmorPiece); + newArmorType = ArmorEquipEvent.ArmorType.match(!isAirOrNull(oldArmorPiece) ? oldArmorPiece : newArmorPiece); } } else if (isAirOrNull(newArmorPiece) && !isAirOrNull(oldArmorPiece)) { - newArmorType = ArmorType.match(oldArmorPiece); + newArmorType = ArmorEquipEvent.ArmorType.match(oldArmorPiece); } if (newArmorType == null || event.getRawSlot() != newArmorType.getSlot()) return; @@ -118,7 +117,7 @@ public void playerInteractEvent(PlayerInteractEvent event) { Player player = event.getPlayer(); ItemStack item = event.getItem(); - ArmorType newArmorType = ArmorType.match(item); + ArmorEquipEvent.ArmorType newArmorType = ArmorEquipEvent.ArmorType.match(item); if (newArmorType == null) return; ItemStack oldArmor = switch (newArmorType) { @@ -154,7 +153,7 @@ public void inventoryDrag(InventoryDragEvent event) { if (!(event.getWhoClicked() instanceof Player player)) return; if (event.getRawSlots().isEmpty()) return; - ArmorType type = ArmorType.match(event.getOldCursor()); + ArmorEquipEvent.ArmorType type = ArmorEquipEvent.ArmorType.match(event.getOldCursor()); if (type == null) return; int slot = event.getRawSlots().stream().findFirst().orElse(-1); @@ -178,7 +177,7 @@ public void inventoryDrag(InventoryDragEvent event) { @EventHandler public void itemBreakEvent(PlayerItemBreakEvent event) { - ArmorType type = ArmorType.match(event.getBrokenItem()); + ArmorEquipEvent.ArmorType type = ArmorEquipEvent.ArmorType.match(event.getBrokenItem()); if (type == null) return; Player player = event.getPlayer(); @@ -225,7 +224,7 @@ public void playerDeathEvent(PlayerDeathEvent event) { Bukkit.getScheduler().runTask(OMCPlugin.getInstance(), () -> Bukkit.getPluginManager().callEvent(new ArmorEquipEvent( player, ArmorEquipEvent.EquipMethod.DEATH, - ArmorType.match(item), + ArmorEquipEvent.ArmorType.match(item), item, null ))); @@ -234,7 +233,7 @@ public void playerDeathEvent(PlayerDeathEvent event) { @EventHandler public void onDispenseArmorEvent(BlockDispenseArmorEvent event) { - ArmorType type = ArmorType.match(event.getItem()); + ArmorEquipEvent.ArmorType type = ArmorEquipEvent.ArmorType.match(event.getItem()); if (type == null) return; if (!(event.getTargetEntity() instanceof Player player)) return; diff --git a/src/main/java/fr/openmc/core/listeners/JoinQuitMessageListener.java b/src/main/java/fr/openmc/core/listeners/JoinQuitMessageListener.java index 2b90029c9..cea5e6c46 100644 --- a/src/main/java/fr/openmc/core/listeners/JoinQuitMessageListener.java +++ b/src/main/java/fr/openmc/core/listeners/JoinQuitMessageListener.java @@ -9,9 +9,9 @@ import fr.openmc.core.features.quests.QuestsManager; import fr.openmc.core.features.quests.objects.Quest; import fr.openmc.core.features.tpa.TPAQueue; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.event.ClickEvent; import org.bukkit.Bukkit; diff --git a/src/main/java/fr/openmc/core/listeners/PlayerDeathListener.java b/src/main/java/fr/openmc/core/listeners/PlayerDeathListener.java index f716aeb6f..16ffa9759 100644 --- a/src/main/java/fr/openmc/core/listeners/PlayerDeathListener.java +++ b/src/main/java/fr/openmc/core/listeners/PlayerDeathListener.java @@ -1,9 +1,9 @@ package fr.openmc.core.listeners; import fr.openmc.core.features.economy.EconomyManager; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; import org.bukkit.entity.Player; 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 5bba4227c..3cedf2ab1 100644 --- a/src/main/java/fr/openmc/core/registry/items/CustomItem.java +++ b/src/main/java/fr/openmc/core/registry/items/CustomItem.java @@ -2,7 +2,7 @@ import dev.lone.itemsadder.api.CustomStack; import fr.openmc.api.hooks.ItemsAdderHook; -import fr.openmc.core.utils.ItemUtils; +import fr.openmc.core.utils.bukkit.ItemUtils; import lombok.Getter; import org.bukkit.inventory.ItemStack; diff --git a/src/main/java/fr/openmc/core/utils/ArmorType.java b/src/main/java/fr/openmc/core/utils/ArmorType.java deleted file mode 100644 index 230f797b0..000000000 --- a/src/main/java/fr/openmc/core/utils/ArmorType.java +++ /dev/null @@ -1,41 +0,0 @@ -package fr.openmc.core.utils; - -import fr.openmc.core.listeners.ArmorListener; -import lombok.Getter; -import org.bukkit.inventory.ItemStack; - -public enum ArmorType { - HELMET(5), - CHESTPLATE(6), - LEGGINGS(7), - BOOTS(8), - ; - - @Getter - private final int slot; - - /** - * Constructor for ArmorType enum. - * - * @param slot The inventory slot associated with the armor type. - */ - ArmorType(int slot) { - this.slot = slot; - } - - /** - * Checks if the item match with the armor type. - * - * @param itemStack The ItemStack to check. - * @return true if the item matches an armor type, false otherwise. - */ - public static ArmorType match(final ItemStack itemStack) { - if(ArmorListener.isAirOrNull(itemStack)) return null; - String type = itemStack.getType().name(); - if(type.endsWith("_HELMET") || type.endsWith("_SKULL") || type.endsWith("_HEAD")) return HELMET; - else if(type.endsWith("_CHESTPLATE") || type.equals("ELYTRA")) return CHESTPLATE; - else if(type.endsWith("_LEGGINGS")) return LEGGINGS; - else if(type.endsWith("_BOOTS")) return BOOTS; - else return null; - } -} diff --git a/src/main/java/fr/openmc/core/utils/DiscordWebhook.java b/src/main/java/fr/openmc/core/utils/DiscordWebhookUtils.java similarity index 97% rename from src/main/java/fr/openmc/core/utils/DiscordWebhook.java rename to src/main/java/fr/openmc/core/utils/DiscordWebhookUtils.java index d1d67992b..ee222c1c6 100644 --- a/src/main/java/fr/openmc/core/utils/DiscordWebhook.java +++ b/src/main/java/fr/openmc/core/utils/DiscordWebhookUtils.java @@ -9,7 +9,7 @@ import java.net.URL; import java.nio.charset.StandardCharsets; -public class DiscordWebhook { +public class DiscordWebhookUtils { /** * Envoie un message vers un webhook Discord via POST JSON. diff --git a/src/main/java/fr/openmc/core/utils/ShutUpOrmLite.java b/src/main/java/fr/openmc/core/utils/ShutUpOrmLite.java deleted file mode 100644 index c58c2900e..000000000 --- a/src/main/java/fr/openmc/core/utils/ShutUpOrmLite.java +++ /dev/null @@ -1,34 +0,0 @@ -package fr.openmc.core.utils; - -import com.j256.ormlite.logger.Level; -import com.j256.ormlite.logger.LocalLogBackend; - -public class ShutUpOrmLite extends LocalLogBackend { - private final String classLabel; - - public ShutUpOrmLite(String classLabel) { - super(classLabel); - this.classLabel = classLabel; - } - - @Override - public boolean isLevelEnabled(Level level) { - return Level.INFO.isEnabled(level); - } - - @Override - public void log(Level level, String msg) { - if (classLabel.contains("com.j256.ormlite.table.TableUtils") || msg.contains("DaoManager created dao for class class")) - return; - - super.log(level, msg); - } - - @Override - public void log(Level level, String msg, Throwable throwable) { - if (classLabel.contains("com.j256.ormlite.table.TableUtils") || msg.contains("DaoManager created dao for class class")) - return; - - super.log(level, msg, throwable); - } -} diff --git a/src/main/java/fr/openmc/core/utils/ItemUtils.java b/src/main/java/fr/openmc/core/utils/bukkit/ItemUtils.java similarity index 98% rename from src/main/java/fr/openmc/core/utils/ItemUtils.java rename to src/main/java/fr/openmc/core/utils/bukkit/ItemUtils.java index 2f82d6e28..88cd4fafd 100644 --- a/src/main/java/fr/openmc/core/utils/ItemUtils.java +++ b/src/main/java/fr/openmc/core/utils/bukkit/ItemUtils.java @@ -1,13 +1,13 @@ -package fr.openmc.core.utils; +package fr.openmc.core.utils.bukkit; import dev.lone.itemsadder.api.CustomStack; import fr.openmc.core.OMCPlugin; import fr.openmc.core.features.mailboxes.MailboxManager; import fr.openmc.core.registry.items.CustomItemRegistry; import fr.openmc.core.utils.cache.CacheOfflinePlayer; -import fr.openmc.core.utils.messages.MessageType; -import fr.openmc.core.utils.messages.MessagesManager; -import fr.openmc.core.utils.messages.Prefix; +import fr.openmc.core.utils.text.messages.MessageType; +import fr.openmc.core.utils.text.messages.MessagesManager; +import fr.openmc.core.utils.text.messages.Prefix; import io.papermc.paper.datacomponent.DataComponentTypes; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.TranslatableComponent; diff --git a/src/main/java/fr/openmc/core/utils/MaterialUtils.java b/src/main/java/fr/openmc/core/utils/bukkit/MaterialUtils.java similarity index 98% rename from src/main/java/fr/openmc/core/utils/MaterialUtils.java rename to src/main/java/fr/openmc/core/utils/bukkit/MaterialUtils.java index f36fd0291..0dd268140 100644 --- a/src/main/java/fr/openmc/core/utils/MaterialUtils.java +++ b/src/main/java/fr/openmc/core/utils/bukkit/MaterialUtils.java @@ -1,4 +1,4 @@ -package fr.openmc.core.utils; +package fr.openmc.core.utils.bukkit; import org.bukkit.Material; import org.bukkit.Tag; diff --git a/src/main/java/fr/openmc/core/utils/ParticleUtils.java b/src/main/java/fr/openmc/core/utils/bukkit/ParticleUtils.java similarity index 98% rename from src/main/java/fr/openmc/core/utils/ParticleUtils.java rename to src/main/java/fr/openmc/core/utils/bukkit/ParticleUtils.java index b498b6575..3bbd0e5fc 100644 --- a/src/main/java/fr/openmc/core/utils/ParticleUtils.java +++ b/src/main/java/fr/openmc/core/utils/bukkit/ParticleUtils.java @@ -1,4 +1,4 @@ -package fr.openmc.core.utils; +package fr.openmc.core.utils.bukkit; import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.math.BlockVector3; @@ -10,6 +10,8 @@ import fr.openmc.core.features.events.contents.weeklyevents.contents.contest.Contest; 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.utils.RandomUtils; +import fr.openmc.core.utils.text.ColorUtils; import net.kyori.adventure.text.format.NamedTextColor; import net.minecraft.core.particles.DustParticleOptions; import net.minecraft.network.protocol.game.ClientboundLevelParticlesPacket; diff --git a/src/main/java/fr/openmc/core/utils/PlayerUtils.java b/src/main/java/fr/openmc/core/utils/bukkit/PlayerUtils.java similarity index 98% rename from src/main/java/fr/openmc/core/utils/PlayerUtils.java rename to src/main/java/fr/openmc/core/utils/bukkit/PlayerUtils.java index 4e544b089..97955cb7a 100644 --- a/src/main/java/fr/openmc/core/utils/PlayerUtils.java +++ b/src/main/java/fr/openmc/core/utils/bukkit/PlayerUtils.java @@ -1,4 +1,4 @@ -package fr.openmc.core.utils; +package fr.openmc.core.utils.bukkit; import dev.lone.itemsadder.api.FontImages.FontImageWrapper; import fr.openmc.core.OMCPlugin; diff --git a/src/main/java/fr/openmc/core/utils/SkullUtils.java b/src/main/java/fr/openmc/core/utils/bukkit/SkullUtils.java similarity index 98% rename from src/main/java/fr/openmc/core/utils/SkullUtils.java rename to src/main/java/fr/openmc/core/utils/bukkit/SkullUtils.java index 15b111ab4..820d96f17 100644 --- a/src/main/java/fr/openmc/core/utils/SkullUtils.java +++ b/src/main/java/fr/openmc/core/utils/bukkit/SkullUtils.java @@ -1,4 +1,4 @@ -package fr.openmc.core.utils; +package fr.openmc.core.utils.bukkit; import com.destroystokyo.paper.profile.PlayerProfile; import com.destroystokyo.paper.profile.ProfileProperty; diff --git a/src/main/java/fr/openmc/core/utils/serializer/BukkitSerializer.java b/src/main/java/fr/openmc/core/utils/bukkit/serializer/BukkitSerializer.java similarity index 97% rename from src/main/java/fr/openmc/core/utils/serializer/BukkitSerializer.java rename to src/main/java/fr/openmc/core/utils/bukkit/serializer/BukkitSerializer.java index 7d9c57e24..9da06945c 100644 --- a/src/main/java/fr/openmc/core/utils/serializer/BukkitSerializer.java +++ b/src/main/java/fr/openmc/core/utils/bukkit/serializer/BukkitSerializer.java @@ -1,4 +1,4 @@ -package fr.openmc.core.utils.serializer; +package fr.openmc.core.utils.bukkit.serializer; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; diff --git a/src/main/java/fr/openmc/core/utils/serializer/LocationSerializer.java b/src/main/java/fr/openmc/core/utils/bukkit/serializer/LocationSerializer.java similarity index 98% rename from src/main/java/fr/openmc/core/utils/serializer/LocationSerializer.java rename to src/main/java/fr/openmc/core/utils/bukkit/serializer/LocationSerializer.java index 5a64d9125..be5cad333 100644 --- a/src/main/java/fr/openmc/core/utils/serializer/LocationSerializer.java +++ b/src/main/java/fr/openmc/core/utils/bukkit/serializer/LocationSerializer.java @@ -1,4 +1,4 @@ -package fr.openmc.core.utils.serializer; +package fr.openmc.core.utils.bukkit.serializer; import org.bukkit.Location; import org.bukkit.World; diff --git a/src/main/java/fr/openmc/core/utils/database/DatabaseManager.java b/src/main/java/fr/openmc/core/utils/database/DatabaseManager.java deleted file mode 100644 index 6b3309d6b..000000000 --- a/src/main/java/fr/openmc/core/utils/database/DatabaseManager.java +++ /dev/null @@ -1,86 +0,0 @@ -package fr.openmc.core.utils.database; - -import com.j256.ormlite.jdbc.JdbcPooledConnectionSource; -import com.j256.ormlite.support.ConnectionSource; -import fr.openmc.api.cooldown.DynamicCooldownManager; -import fr.openmc.core.OMCPlugin; -import fr.openmc.core.features.analytics.AnalyticsManager; -import fr.openmc.core.features.city.CityManager; -import fr.openmc.core.features.city.sub.mascots.MascotsManager; -import fr.openmc.core.features.city.sub.mayor.managers.MayorManager; -import fr.openmc.core.features.city.sub.notation.NotationManager; -import fr.openmc.core.features.city.sub.rank.CityRankManager; -import fr.openmc.core.features.city.sub.statistics.CityStatisticsManager; -import fr.openmc.core.features.city.sub.war.WarManager; -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.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.FriendSQLManager; -import fr.openmc.core.features.homes.HomesManager; -import fr.openmc.core.features.mailboxes.MailboxManager; -import fr.openmc.core.features.milestones.MilestonesManager; -import fr.openmc.core.features.settings.PlayerSettingsManager; -import lombok.Getter; -import org.bukkit.configuration.file.FileConfiguration; - -import java.nio.channels.ConnectionPendingException; -import java.sql.SQLException; - -public class DatabaseManager { - @Getter - private static ConnectionSource connectionSource; - - public static void init() { - try { - if (OMCPlugin.isUnitTestVersion()) { - Class.forName("org.h2.Driver"); - } else { - Class.forName("com.mysql.cj.jdbc.Driver"); - } - } catch (ClassNotFoundException e) { - OMCPlugin.getInstance().getSLF4JLogger().error("Database driver not found. Please ensure the MySQL or H2 driver is included in the classpath."); - throw new RuntimeException(e); - } - - // ormlite - try { - FileConfiguration config = OMCPlugin.getConfigs(); - String databaseUrl = config.getString("database.url"); - String username = config.getString("database.username"); - String password = config.getString("database.password"); - connectionSource = new JdbcPooledConnectionSource(databaseUrl, username, password); - - DreamManager.initDB(connectionSource); - WarManager.initDB(connectionSource); - NotationManager.initDB(connectionSource); - MayorManager.initDB(connectionSource); - MilestonesManager.initDB(connectionSource); - BankManager.initDB(connectionSource); - TransactionsManager.initDB(connectionSource); - AnalyticsManager.initDB(connectionSource); - MailboxManager.initDB(connectionSource); - ContestManager.initDB(connectionSource); - WeeklyEventsManager.initDB(connectionSource); - EconomyManager.initDB(connectionSource); - HomesManager.initDB(connectionSource); - FriendSQLManager.initDB(connectionSource); - DynamicCooldownManager.initDB(connectionSource); - CityManager.initDB(connectionSource); - CityRankManager.initDB(connectionSource); - MascotsManager.initDB(connectionSource); - PlayerSettingsManager.initDB(connectionSource); - CityStatisticsManager.initDB(connectionSource); - HalloweenManager.initDB(connectionSource); - } catch (SQLException e) { - OMCPlugin.getInstance().getSLF4JLogger().error("Failed to initialize the database connection.", e); - throw new RuntimeException(e); - } catch (ConnectionPendingException e) { - OMCPlugin.getInstance().getSLF4JLogger().error("Database connection is pending. Please check your database configuration."); - throw new RuntimeException(e); - } - } -} diff --git a/src/main/java/fr/openmc/core/utils/init/DatabaseFeature.java b/src/main/java/fr/openmc/core/utils/init/DatabaseFeature.java new file mode 100644 index 000000000..056b1d05e --- /dev/null +++ b/src/main/java/fr/openmc/core/utils/init/DatabaseFeature.java @@ -0,0 +1,13 @@ +package fr.openmc.core.utils.init; + +import com.j256.ormlite.support.ConnectionSource; + +import java.sql.SQLException; + +/** + * Interface permettant aux features d'initialiser leur base de données lors du démarrage du plugin. + */ +public interface DatabaseFeature { + void initDB(ConnectionSource connectionSource) throws SQLException; +} + diff --git a/src/main/java/fr/openmc/core/utils/init/Feature.java b/src/main/java/fr/openmc/core/utils/init/Feature.java new file mode 100644 index 000000000..fd40897e8 --- /dev/null +++ b/src/main/java/fr/openmc/core/utils/init/Feature.java @@ -0,0 +1,40 @@ +package fr.openmc.core.utils.init; + +import com.j256.ormlite.support.ConnectionSource; +import fr.openmc.core.OMCPlugin; + +import java.sql.SQLException; + +public abstract class Feature { + protected boolean initialize = false; + + public void startInit() { + if (this instanceof NotUnitTestFeature && OMCPlugin.isUnitTestVersion()) return; + try { + init(); + initialize = true; + } catch (Exception e) { + initialize = false; + throw e; + } + } + + public final void startDB(ConnectionSource connectionSource) throws SQLException { + if (this instanceof NotUnitTestFeature && OMCPlugin.isUnitTestVersion()) return; + if (this instanceof DatabaseFeature dbF) { + dbF.initDB(connectionSource); + } + } + + public final void startSave() { + if (!initialize) return; + save(); + } + + public final boolean isInitialized() { + return initialize; + } + + protected abstract void init(); + protected abstract void save(); +} diff --git a/src/main/java/fr/openmc/core/utils/init/LoadAfterItemsAdder.java b/src/main/java/fr/openmc/core/utils/init/LoadAfterItemsAdder.java new file mode 100644 index 000000000..94891d3b0 --- /dev/null +++ b/src/main/java/fr/openmc/core/utils/init/LoadAfterItemsAdder.java @@ -0,0 +1,7 @@ +package fr.openmc.core.utils.init; + +/** + * Charge la feature apres ItemsAdder + */ +public interface LoadAfterItemsAdder { } + diff --git a/src/main/java/fr/openmc/core/utils/init/NotUnitTestFeature.java b/src/main/java/fr/openmc/core/utils/init/NotUnitTestFeature.java new file mode 100644 index 000000000..f15dc4cf5 --- /dev/null +++ b/src/main/java/fr/openmc/core/utils/init/NotUnitTestFeature.java @@ -0,0 +1,7 @@ +package fr.openmc.core.utils.init; + +/** + * Exclu la feature a ne pas etre chargé sur la version de test + */ +public interface NotUnitTestFeature { } + diff --git a/src/main/java/fr/openmc/core/utils/ColorUtils.java b/src/main/java/fr/openmc/core/utils/text/ColorUtils.java similarity index 99% rename from src/main/java/fr/openmc/core/utils/ColorUtils.java rename to src/main/java/fr/openmc/core/utils/text/ColorUtils.java index d13f47ac0..8f45d0952 100644 --- a/src/main/java/fr/openmc/core/utils/ColorUtils.java +++ b/src/main/java/fr/openmc/core/utils/text/ColorUtils.java @@ -1,4 +1,4 @@ -package fr.openmc.core.utils; +package fr.openmc.core.utils.text; import net.kyori.adventure.text.format.NamedTextColor; import org.bukkit.Material; diff --git a/src/main/java/fr/openmc/core/utils/DateUtils.java b/src/main/java/fr/openmc/core/utils/text/DateUtils.java similarity index 99% rename from src/main/java/fr/openmc/core/utils/DateUtils.java rename to src/main/java/fr/openmc/core/utils/text/DateUtils.java index 3fd482348..0086dcff8 100644 --- a/src/main/java/fr/openmc/core/utils/DateUtils.java +++ b/src/main/java/fr/openmc/core/utils/text/DateUtils.java @@ -1,4 +1,4 @@ -package fr.openmc.core.utils; +package fr.openmc.core.utils.text; import java.time.DayOfWeek; import java.time.Duration; diff --git a/src/main/java/fr/openmc/core/utils/DirectionUtils.java b/src/main/java/fr/openmc/core/utils/text/DirectionUtils.java similarity index 98% rename from src/main/java/fr/openmc/core/utils/DirectionUtils.java rename to src/main/java/fr/openmc/core/utils/text/DirectionUtils.java index 6ac594ad6..a0e716e1f 100644 --- a/src/main/java/fr/openmc/core/utils/DirectionUtils.java +++ b/src/main/java/fr/openmc/core/utils/text/DirectionUtils.java @@ -1,4 +1,4 @@ -package fr.openmc.core.utils; +package fr.openmc.core.utils.text; import org.bukkit.Location; import org.bukkit.entity.Player; diff --git a/src/main/java/fr/openmc/core/utils/InputUtils.java b/src/main/java/fr/openmc/core/utils/text/InputUtils.java similarity index 98% rename from src/main/java/fr/openmc/core/utils/InputUtils.java rename to src/main/java/fr/openmc/core/utils/text/InputUtils.java index 53685b60d..976d56984 100644 --- a/src/main/java/fr/openmc/core/utils/InputUtils.java +++ b/src/main/java/fr/openmc/core/utils/text/InputUtils.java @@ -1,4 +1,4 @@ -package fr.openmc.core.utils; +package fr.openmc.core.utils.text; import fr.openmc.core.features.city.City; import fr.openmc.core.features.city.CityManager; diff --git a/src/main/java/fr/openmc/core/utils/MotdUtils.java b/src/main/java/fr/openmc/core/utils/text/MotdUtils.java similarity index 85% rename from src/main/java/fr/openmc/core/utils/MotdUtils.java rename to src/main/java/fr/openmc/core/utils/text/MotdUtils.java index deb38f590..72f9e3e2a 100644 --- a/src/main/java/fr/openmc/core/utils/MotdUtils.java +++ b/src/main/java/fr/openmc/core/utils/text/MotdUtils.java @@ -1,6 +1,7 @@ -package fr.openmc.core.utils; +package fr.openmc.core.utils.text; import fr.openmc.core.OMCPlugin; +import fr.openmc.core.bootstrap.features.Feature; import net.kyori.adventure.text.Component; import org.bukkit.Bukkit; import org.bukkit.configuration.file.YamlConfiguration; @@ -11,11 +12,12 @@ import java.util.Map; import java.util.Random; -public class MotdUtils { +public class MotdUtils extends Feature { private static Component motd; private static YamlConfiguration motdConfig = null; - public static void init() { + @Override + public void init() { File motdFile = new File(OMCPlugin.getInstance().getDataFolder() + "/data", "motd.yml"); if (!motdFile.exists()) { @@ -42,4 +44,9 @@ public void run() { } }.runTaskTimer(OMCPlugin.getInstance(), 0L, 12000L); // 12 000 ticks = 10 minutes } + + @Override + public void save() { + // nothing to save + } } diff --git a/src/main/java/fr/openmc/core/utils/PaddingUtils.java b/src/main/java/fr/openmc/core/utils/text/PaddingUtils.java similarity index 90% rename from src/main/java/fr/openmc/core/utils/PaddingUtils.java rename to src/main/java/fr/openmc/core/utils/text/PaddingUtils.java index f0afd969c..dfbac05f5 100644 --- a/src/main/java/fr/openmc/core/utils/PaddingUtils.java +++ b/src/main/java/fr/openmc/core/utils/text/PaddingUtils.java @@ -1,4 +1,4 @@ -package fr.openmc.core.utils; +package fr.openmc.core.utils.text; public class PaddingUtils { diff --git a/src/main/java/fr/openmc/core/utils/translation/TranslationManager.java b/src/main/java/fr/openmc/core/utils/text/TranslationManager.java similarity index 93% rename from src/main/java/fr/openmc/core/utils/translation/TranslationManager.java rename to src/main/java/fr/openmc/core/utils/text/TranslationManager.java index 3bd84e8bd..020e2a7b7 100644 --- a/src/main/java/fr/openmc/core/utils/translation/TranslationManager.java +++ b/src/main/java/fr/openmc/core/utils/text/TranslationManager.java @@ -1,6 +1,7 @@ -package fr.openmc.core.utils.translation; +package fr.openmc.core.utils.text; import fr.openmc.core.OMCPlugin; +import fr.openmc.core.bootstrap.features.Feature; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.YamlConfiguration; @@ -10,19 +11,27 @@ import java.util.Objects; -public class TranslationManager { +public class TranslationManager extends Feature { private static String defaultLanguage; private static File translationFolder; private static final Map loadedLanguages = new HashMap<>(); - - public static void init(File inTranslationFolder, String inDefaultLanguage) { + public TranslationManager(File inTranslationFolder, String inDefaultLanguage) { defaultLanguage = inDefaultLanguage; translationFolder = inTranslationFolder; + } + @Override + public void init() { loadAllLanguages(); } + + @Override + public void save() { + + } + /** * Returns a string corresponding to the specified path and the language. * diff --git a/src/main/java/fr/openmc/core/utils/customfonts/CustomFonts.java b/src/main/java/fr/openmc/core/utils/text/fonts/CustomFonts.java similarity index 93% rename from src/main/java/fr/openmc/core/utils/customfonts/CustomFonts.java rename to src/main/java/fr/openmc/core/utils/text/fonts/CustomFonts.java index 328ee9280..8a649cadf 100644 --- a/src/main/java/fr/openmc/core/utils/customfonts/CustomFonts.java +++ b/src/main/java/fr/openmc/core/utils/text/fonts/CustomFonts.java @@ -1,4 +1,4 @@ -package fr.openmc.core.utils.customfonts; +package fr.openmc.core.utils.text.fonts; import fr.openmc.api.hooks.ItemsAdderHook; diff --git a/src/main/java/fr/openmc/core/utils/customfonts/Fonts.java b/src/main/java/fr/openmc/core/utils/text/fonts/Fonts.java similarity index 83% rename from src/main/java/fr/openmc/core/utils/customfonts/Fonts.java rename to src/main/java/fr/openmc/core/utils/text/fonts/Fonts.java index fc122432a..e585db01d 100644 --- a/src/main/java/fr/openmc/core/utils/customfonts/Fonts.java +++ b/src/main/java/fr/openmc/core/utils/text/fonts/Fonts.java @@ -1,4 +1,4 @@ -package fr.openmc.core.utils.customfonts; +package fr.openmc.core.utils.text.fonts; import dev.lone.itemsadder.api.FontImages.FontImageWrapper; diff --git a/src/main/java/fr/openmc/core/utils/messages/MessageType.java b/src/main/java/fr/openmc/core/utils/text/messages/MessageType.java similarity index 91% rename from src/main/java/fr/openmc/core/utils/messages/MessageType.java rename to src/main/java/fr/openmc/core/utils/text/messages/MessageType.java index e31bede9f..7993e7c8c 100644 --- a/src/main/java/fr/openmc/core/utils/messages/MessageType.java +++ b/src/main/java/fr/openmc/core/utils/text/messages/MessageType.java @@ -1,4 +1,4 @@ -package fr.openmc.core.utils.messages; +package fr.openmc.core.utils.text.messages; import lombok.Getter; import org.bukkit.Sound; diff --git a/src/main/java/fr/openmc/core/utils/messages/MessagesManager.java b/src/main/java/fr/openmc/core/utils/text/messages/MessagesManager.java similarity index 99% rename from src/main/java/fr/openmc/core/utils/messages/MessagesManager.java rename to src/main/java/fr/openmc/core/utils/text/messages/MessagesManager.java index b97fbda99..168498837 100644 --- a/src/main/java/fr/openmc/core/utils/messages/MessagesManager.java +++ b/src/main/java/fr/openmc/core/utils/text/messages/MessagesManager.java @@ -1,4 +1,4 @@ -package fr.openmc.core.utils.messages; +package fr.openmc.core.utils.text.messages; import fr.openmc.core.features.settings.PlayerSettingsManager; import lombok.Getter; diff --git a/src/main/java/fr/openmc/core/utils/messages/Prefix.java b/src/main/java/fr/openmc/core/utils/text/messages/Prefix.java similarity index 97% rename from src/main/java/fr/openmc/core/utils/messages/Prefix.java rename to src/main/java/fr/openmc/core/utils/text/messages/Prefix.java index 93872634b..9e2e50c2c 100644 --- a/src/main/java/fr/openmc/core/utils/messages/Prefix.java +++ b/src/main/java/fr/openmc/core/utils/text/messages/Prefix.java @@ -1,4 +1,4 @@ -package fr.openmc.core.utils.messages; +package fr.openmc.core.utils.text.messages; import lombok.Getter; import net.kyori.adventure.text.Component; diff --git a/src/main/java/fr/openmc/core/utils/EntityUtils.java b/src/main/java/fr/openmc/core/utils/world/EntityUtils.java similarity index 96% rename from src/main/java/fr/openmc/core/utils/EntityUtils.java rename to src/main/java/fr/openmc/core/utils/world/EntityUtils.java index 24fd2e916..18be912c2 100644 --- a/src/main/java/fr/openmc/core/utils/EntityUtils.java +++ b/src/main/java/fr/openmc/core/utils/world/EntityUtils.java @@ -1,4 +1,4 @@ -package fr.openmc.core.utils; +package fr.openmc.core.utils.world; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.TranslatableComponent; diff --git a/src/main/java/fr/openmc/core/utils/LocationUtils.java b/src/main/java/fr/openmc/core/utils/world/LocationUtils.java similarity index 98% rename from src/main/java/fr/openmc/core/utils/LocationUtils.java rename to src/main/java/fr/openmc/core/utils/world/LocationUtils.java index 8e9a61fc4..1bc4b56ab 100644 --- a/src/main/java/fr/openmc/core/utils/LocationUtils.java +++ b/src/main/java/fr/openmc/core/utils/world/LocationUtils.java @@ -1,4 +1,4 @@ -package fr.openmc.core.utils; +package fr.openmc.core.utils.world; import org.bukkit.Location; import org.bukkit.World; diff --git a/src/main/java/fr/openmc/core/utils/ChunkInfo.java b/src/main/java/fr/openmc/core/utils/world/chunk/ChunkInfo.java similarity index 71% rename from src/main/java/fr/openmc/core/utils/ChunkInfo.java rename to src/main/java/fr/openmc/core/utils/world/chunk/ChunkInfo.java index baac4cbe9..e8362bc7c 100644 --- a/src/main/java/fr/openmc/core/utils/ChunkInfo.java +++ b/src/main/java/fr/openmc/core/utils/world/chunk/ChunkInfo.java @@ -1,4 +1,4 @@ -package fr.openmc.core.utils; +package fr.openmc.core.utils.world.chunk; import fr.openmc.core.features.city.City; diff --git a/src/main/java/fr/openmc/core/utils/ChunkPos.java b/src/main/java/fr/openmc/core/utils/world/chunk/ChunkPos.java similarity index 96% rename from src/main/java/fr/openmc/core/utils/ChunkPos.java rename to src/main/java/fr/openmc/core/utils/world/chunk/ChunkPos.java index f46483d1f..029247019 100644 --- a/src/main/java/fr/openmc/core/utils/ChunkPos.java +++ b/src/main/java/fr/openmc/core/utils/world/chunk/ChunkPos.java @@ -1,4 +1,4 @@ -package fr.openmc.core.utils; +package fr.openmc.core.utils.world.chunk; import org.bukkit.Bukkit; import org.bukkit.Chunk; diff --git a/src/main/java/fr/openmc/core/utils/entities/TextDisplay.java b/src/main/java/fr/openmc/core/utils/world/entities/TextDisplay.java similarity index 99% rename from src/main/java/fr/openmc/core/utils/entities/TextDisplay.java rename to src/main/java/fr/openmc/core/utils/world/entities/TextDisplay.java index 33625e24a..d6d668383 100644 --- a/src/main/java/fr/openmc/core/utils/entities/TextDisplay.java +++ b/src/main/java/fr/openmc/core/utils/world/entities/TextDisplay.java @@ -1,4 +1,4 @@ -package fr.openmc.core.utils.entities; +package fr.openmc.core.utils.world.entities; import com.mojang.math.Transformation; import io.papermc.paper.adventure.PaperAdventure; diff --git a/src/main/java/fr/openmc/core/utils/structure/FeaturesPopulator.java b/src/main/java/fr/openmc/core/utils/world/structure/FeaturesPopulator.java similarity index 95% rename from src/main/java/fr/openmc/core/utils/structure/FeaturesPopulator.java rename to src/main/java/fr/openmc/core/utils/world/structure/FeaturesPopulator.java index 4cfc87600..70509fe5b 100644 --- a/src/main/java/fr/openmc/core/utils/structure/FeaturesPopulator.java +++ b/src/main/java/fr/openmc/core/utils/world/structure/FeaturesPopulator.java @@ -1,4 +1,4 @@ -package fr.openmc.core.utils.structure; +package fr.openmc.core.utils.world.structure; import org.bukkit.Location; import org.bukkit.generator.BlockPopulator; diff --git a/src/main/java/fr/openmc/core/utils/structure/SchematicsUtils.java b/src/main/java/fr/openmc/core/utils/world/structure/SchematicsUtils.java similarity index 99% rename from src/main/java/fr/openmc/core/utils/structure/SchematicsUtils.java rename to src/main/java/fr/openmc/core/utils/world/structure/SchematicsUtils.java index 737dac76f..aae37f36d 100644 --- a/src/main/java/fr/openmc/core/utils/structure/SchematicsUtils.java +++ b/src/main/java/fr/openmc/core/utils/world/structure/SchematicsUtils.java @@ -1,4 +1,4 @@ -package fr.openmc.core.utils.structure; +package fr.openmc.core.utils.world.structure; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.WorldEdit; diff --git a/src/main/java/fr/openmc/core/utils/structure/StructureUtils.java b/src/main/java/fr/openmc/core/utils/world/structure/StructureUtils.java similarity index 99% rename from src/main/java/fr/openmc/core/utils/structure/StructureUtils.java rename to src/main/java/fr/openmc/core/utils/world/structure/StructureUtils.java index afb5d8cc7..c8178942c 100644 --- a/src/main/java/fr/openmc/core/utils/structure/StructureUtils.java +++ b/src/main/java/fr/openmc/core/utils/world/structure/StructureUtils.java @@ -1,7 +1,7 @@ -package fr.openmc.core.utils.structure; +package fr.openmc.core.utils.world.structure; -import com.flowpowered.nbt.Tag; import com.flowpowered.nbt.*; +import com.flowpowered.nbt.Tag; import com.flowpowered.nbt.stream.NBTInputStream; import fr.openmc.core.OMCPlugin; import net.minecraft.core.BlockPos; diff --git a/src/test/java/fr/openmc/core/utils/ColorUtilsTest.java b/src/test/java/fr/openmc/core/utils/ColorUtilsTest.java index da0958d96..99ae8ee43 100644 --- a/src/test/java/fr/openmc/core/utils/ColorUtilsTest.java +++ b/src/test/java/fr/openmc/core/utils/ColorUtilsTest.java @@ -1,5 +1,6 @@ package fr.openmc.core.utils; +import fr.openmc.core.utils.text.ColorUtils; import net.kyori.adventure.text.format.NamedTextColor; import org.bukkit.Material; import org.junit.jupiter.api.Assertions; diff --git a/src/test/java/fr/openmc/core/utils/DateUtilsTest.java b/src/test/java/fr/openmc/core/utils/DateUtilsTest.java index 865ea00a4..32f1ad94e 100644 --- a/src/test/java/fr/openmc/core/utils/DateUtilsTest.java +++ b/src/test/java/fr/openmc/core/utils/DateUtilsTest.java @@ -1,5 +1,6 @@ package fr.openmc.core.utils; +import fr.openmc.core.utils.text.DateUtils; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; diff --git a/src/test/java/fr/openmc/core/utils/InputUtilsTest.java b/src/test/java/fr/openmc/core/utils/InputUtilsTest.java index a399df5f3..f5e4c061c 100644 --- a/src/test/java/fr/openmc/core/utils/InputUtilsTest.java +++ b/src/test/java/fr/openmc/core/utils/InputUtilsTest.java @@ -1,5 +1,6 @@ package fr.openmc.core.utils; +import fr.openmc.core.utils.text.InputUtils; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; diff --git a/src/test/java/fr/openmc/core/utils/ItemsUtilTest.java b/src/test/java/fr/openmc/core/utils/ItemsUtilTest.java index 2d2386b21..1505d9fa9 100644 --- a/src/test/java/fr/openmc/core/utils/ItemsUtilTest.java +++ b/src/test/java/fr/openmc/core/utils/ItemsUtilTest.java @@ -1,5 +1,6 @@ package fr.openmc.core.utils; +import fr.openmc.core.utils.bukkit.ItemUtils; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; import org.junit.jupiter.api.Assertions; diff --git a/src/test/java/fr/openmc/core/utils/PaddingUtilsTest.java b/src/test/java/fr/openmc/core/utils/PaddingUtilsTest.java index 14639345b..2c75a4199 100644 --- a/src/test/java/fr/openmc/core/utils/PaddingUtilsTest.java +++ b/src/test/java/fr/openmc/core/utils/PaddingUtilsTest.java @@ -1,5 +1,6 @@ package fr.openmc.core.utils; +import fr.openmc.core.utils.text.PaddingUtils; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; From 14d71cfdb4640558d33e6933fb3fd95c04079993 Mon Sep 17 00:00:00 2001 From: iambibi_ <89582596+iambibi@users.noreply.github.com> Date: Tue, 7 Apr 2026 19:14:51 +0200 Subject: [PATCH 2/2] fix build --- .../core/bootstrap/features/types/NotInUnitTest.java | 7 +++++++ .../core/features/displays/holograms/HologramLoader.java | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 src/main/java/fr/openmc/core/bootstrap/features/types/NotInUnitTest.java diff --git a/src/main/java/fr/openmc/core/bootstrap/features/types/NotInUnitTest.java b/src/main/java/fr/openmc/core/bootstrap/features/types/NotInUnitTest.java new file mode 100644 index 000000000..c61d52978 --- /dev/null +++ b/src/main/java/fr/openmc/core/bootstrap/features/types/NotInUnitTest.java @@ -0,0 +1,7 @@ +package fr.openmc.core.bootstrap.features.types; + +/** + * Charge uniquement la feature hors des tests unitaires + */ +public interface NotInUnitTest {} + 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 8a38db7a6..8be67f511 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 @@ -27,7 +27,7 @@ public class HologramLoader extends Feature implements NotInUnitTest, LoadAfterI public static final HashMap displays = new HashMap<>(); private static BukkitTask taskTimer; - private static File hologramFolder; + public static File hologramFolder; public static File getHologramFolder() { if (hologramFolder == null) {