├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ ├── demande-de-changement-.md │ └── demande-de-feature.md ├── issue_template.md ├── pull_request_template.md ├── release.yml └── workflows │ ├── build-test.yml │ ├── check-milestone.yml │ ├── milestone-close.yml │ ├── release-to-discord.yml │ └── tag-sync.yml ├── .gitignore ├── .idea └── icon.svg ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle ├── src ├── main │ ├── java │ │ └── fr │ │ │ └── openmc │ │ │ ├── api │ │ │ ├── chronometer │ │ │ │ ├── Chronometer.java │ │ │ │ ├── ChronometerInfo.java │ │ │ │ └── ChronometerType.java │ │ │ ├── cooldown │ │ │ │ ├── CooldownEndEvent.java │ │ │ │ ├── CooldownInterceptor.java │ │ │ │ ├── CooldownStartEvent.java │ │ │ │ ├── DynamicCooldown.java │ │ │ │ └── DynamicCooldownManager.java │ │ │ ├── input │ │ │ │ ├── ChatInput.java │ │ │ │ ├── location │ │ │ │ │ ├── InteractionInfo.java │ │ │ │ │ └── ItemInteraction.java │ │ │ │ └── signgui │ │ │ │ │ ├── SignEditor.java │ │ │ │ │ ├── SignGUI.java │ │ │ │ │ ├── SignGUIAction.java │ │ │ │ │ ├── SignGUIBuilder.java │ │ │ │ │ ├── SignGUIChannelHandler.java │ │ │ │ │ ├── SignGUIFinishHandler.java │ │ │ │ │ ├── SignGUIResult.java │ │ │ │ │ ├── exception │ │ │ │ │ ├── SignGUIException.java │ │ │ │ │ └── SignGUIVersionException.java │ │ │ │ │ └── wrapper │ │ │ │ │ └── MojangWrapper.java │ │ │ ├── menulib │ │ │ │ ├── Menu.java │ │ │ │ ├── MenuLib.java │ │ │ │ ├── PaginatedMenu.java │ │ │ │ ├── default_menu │ │ │ │ │ └── ConfirmMenu.java │ │ │ │ └── utils │ │ │ │ │ ├── InventorySize.java │ │ │ │ │ ├── ItemBuilder.java │ │ │ │ │ ├── ItemUtils.java │ │ │ │ │ ├── MenuUtils.java │ │ │ │ │ └── StaticSlots.java │ │ │ └── packetmenulib │ │ │ │ ├── PacketListener.java │ │ │ │ ├── PacketMenuLib.java │ │ │ │ ├── events │ │ │ │ ├── InventoryClickEvent.java │ │ │ │ └── InventoryCloseEvent.java │ │ │ │ ├── menu │ │ │ │ ├── ClickType.java │ │ │ │ ├── InventoryType.java │ │ │ │ └── Menu.java │ │ │ │ └── utils │ │ │ │ └── PacketUtils.java │ │ │ └── core │ │ │ ├── CommandsManager.java │ │ │ ├── ListenersManager.java │ │ │ ├── OMCPlugin.java │ │ │ ├── commands │ │ │ ├── admin │ │ │ │ └── freeze │ │ │ │ │ ├── FreezeCommand.java │ │ │ │ │ ├── FreezeListener.java │ │ │ │ │ └── FreezeManager.java │ │ │ ├── debug │ │ │ │ ├── ChronometerCommand.java │ │ │ │ └── CooldownCommand.java │ │ │ ├── fun │ │ │ │ ├── Diceroll.java │ │ │ │ └── Playtime.java │ │ │ └── utils │ │ │ │ ├── Restart.java │ │ │ │ ├── Rtp.java │ │ │ │ ├── SetSpawn.java │ │ │ │ ├── Socials.java │ │ │ │ ├── Spawn.java │ │ │ │ └── SpawnManager.java │ │ │ ├── features │ │ │ ├── accountdetection │ │ │ │ ├── AccountDetectionManager.java │ │ │ │ └── commands │ │ │ │ │ └── AccountDetectionCommand.java │ │ │ ├── adminshop │ │ │ │ ├── AdminShopCommand.java │ │ │ │ ├── AdminShopManager.java │ │ │ │ ├── AdminShopUtils.java │ │ │ │ ├── AdminShopYAML.java │ │ │ │ ├── ShopCategory.java │ │ │ │ ├── ShopItem.java │ │ │ │ ├── events │ │ │ │ │ ├── BuyEvent.java │ │ │ │ │ └── SellEvent.java │ │ │ │ └── menus │ │ │ │ │ ├── AdminShopCategoryMenu.java │ │ │ │ │ ├── AdminShopMenu.java │ │ │ │ │ ├── ColorVariantsMenu.java │ │ │ │ │ └── ConfirmMenu.java │ │ │ ├── analytics │ │ │ │ ├── AnalyticsManager.java │ │ │ │ ├── Stats.java │ │ │ │ └── models │ │ │ │ │ └── Statistic.java │ │ │ ├── city │ │ │ │ ├── CPermission.java │ │ │ │ ├── ChunkDataCache.java │ │ │ │ ├── City.java │ │ │ │ ├── CityChatManager.java │ │ │ │ ├── CityManager.java │ │ │ │ ├── CityMessages.java │ │ │ │ ├── CityType.java │ │ │ │ ├── ProtectionsManager.java │ │ │ │ ├── actions │ │ │ │ │ ├── CityChangeAction.java │ │ │ │ │ ├── CityChestAction.java │ │ │ │ │ ├── CityClaimAction.java │ │ │ │ │ ├── CityCreateAction.java │ │ │ │ │ ├── CityDeleteAction.java │ │ │ │ │ ├── CityKickAction.java │ │ │ │ │ ├── CityLeaveAction.java │ │ │ │ │ ├── CityTransferAction.java │ │ │ │ │ ├── CityUnclaimAction.java │ │ │ │ │ └── MayorSetWarpAction.java │ │ │ │ ├── commands │ │ │ │ │ ├── AdminCityCommands.java │ │ │ │ │ ├── CityChatCommand.java │ │ │ │ │ ├── CityChestCommand.java │ │ │ │ │ ├── CityCommands.java │ │ │ │ │ └── CityPermsCommands.java │ │ │ │ ├── conditions │ │ │ │ │ ├── CityChestConditions.java │ │ │ │ │ ├── CityClaimCondition.java │ │ │ │ │ ├── CityCreateConditions.java │ │ │ │ │ ├── CityInviteConditions.java │ │ │ │ │ ├── CityKickCondition.java │ │ │ │ │ ├── CityLeaveCondition.java │ │ │ │ │ ├── CityManageConditions.java │ │ │ │ │ ├── CityTypeConditions.java │ │ │ │ │ └── CityUnclaimCondition.java │ │ │ │ ├── events │ │ │ │ │ ├── CityCreationEvent.java │ │ │ │ │ ├── CityDeleteEvent.java │ │ │ │ │ ├── CityMoneyUpdateEvent.java │ │ │ │ │ ├── CityPermissionChangeEvent.java │ │ │ │ │ ├── CityRenameEvent.java │ │ │ │ │ ├── MemberJoinEvent.java │ │ │ │ │ └── MemberLeaveEvent.java │ │ │ │ ├── listeners │ │ │ │ │ ├── CityChatListener.java │ │ │ │ │ └── protections │ │ │ │ │ │ ├── BlockProtection.java │ │ │ │ │ │ ├── BowProtection.java │ │ │ │ │ │ ├── CityExplosionData.java │ │ │ │ │ │ ├── DamageProtection.java │ │ │ │ │ │ ├── EntityProtection.java │ │ │ │ │ │ ├── ExplodeProtection.java │ │ │ │ │ │ ├── FireProtection.java │ │ │ │ │ │ ├── FishProtection.java │ │ │ │ │ │ ├── FoodProtection.java │ │ │ │ │ │ ├── HangingProtection.java │ │ │ │ │ │ ├── InteractProtection.java │ │ │ │ │ │ ├── LeashProtection.java │ │ │ │ │ │ ├── MountProtection.java │ │ │ │ │ │ ├── PistonProtection.java │ │ │ │ │ │ ├── PotionProtection.java │ │ │ │ │ │ ├── TeleportProtection.java │ │ │ │ │ │ ├── TramplingProtection.java │ │ │ │ │ │ └── VehicleProtection.java │ │ │ │ ├── menu │ │ │ │ │ ├── CitizensPermsMenu.java │ │ │ │ │ ├── CityChestMenu.java │ │ │ │ │ ├── CityChunkMenu.java │ │ │ │ │ ├── CityMenu.java │ │ │ │ │ ├── CityModifyMenu.java │ │ │ │ │ ├── CityTransferMenu.java │ │ │ │ │ ├── CityTypeMenu.java │ │ │ │ │ ├── InvitationsMenu.java │ │ │ │ │ ├── NoCityMenu.java │ │ │ │ │ ├── list │ │ │ │ │ │ ├── CityListDetailsMenu.java │ │ │ │ │ │ ├── CityListMenu.java │ │ │ │ │ │ └── CityPlayerListMenu.java │ │ │ │ │ └── playerlist │ │ │ │ │ │ ├── CityPlayerGestionMenu.java │ │ │ │ │ │ └── CityPlayerListMenu.java │ │ │ │ ├── models │ │ │ │ │ ├── DBCity.java │ │ │ │ │ ├── DBCityChest.java │ │ │ │ │ ├── DBCityClaim.java │ │ │ │ │ ├── DBCityMember.java │ │ │ │ │ └── DBCityPermission.java │ │ │ │ └── sub │ │ │ │ │ ├── bank │ │ │ │ │ ├── CityBankManager.java │ │ │ │ │ ├── commands │ │ │ │ │ │ └── CityBankCommand.java │ │ │ │ │ ├── conditions │ │ │ │ │ │ └── CityBankConditions.java │ │ │ │ │ └── menu │ │ │ │ │ │ ├── CityBankDepositMenu.java │ │ │ │ │ │ ├── CityBankMenu.java │ │ │ │ │ │ └── CityBankWithdrawMenu.java │ │ │ │ │ ├── mascots │ │ │ │ │ ├── MascotsLevels.java │ │ │ │ │ ├── MascotsManager.java │ │ │ │ │ ├── commands │ │ │ │ │ │ └── AdminMascotsCommands.java │ │ │ │ │ ├── listeners │ │ │ │ │ │ ├── MascotImmuneListener.java │ │ │ │ │ │ ├── MascotsDamageListener.java │ │ │ │ │ │ ├── MascotsDeathListener.java │ │ │ │ │ │ ├── MascotsInteractionListener.java │ │ │ │ │ │ ├── MascotsProtectionsListener.java │ │ │ │ │ │ └── MascotsTargetListener.java │ │ │ │ │ ├── menu │ │ │ │ │ │ ├── MascotMenu.java │ │ │ │ │ │ ├── MascotsDeadMenu.java │ │ │ │ │ │ └── MascotsSkinMenu.java │ │ │ │ │ ├── models │ │ │ │ │ │ └── Mascot.java │ │ │ │ │ └── utils │ │ │ │ │ │ ├── MascotRegenerationUtils.java │ │ │ │ │ │ └── MascotUtils.java │ │ │ │ │ ├── mayor │ │ │ │ │ ├── ElectionType.java │ │ │ │ │ ├── actions │ │ │ │ │ │ └── MayorCommandAction.java │ │ │ │ │ ├── commands │ │ │ │ │ │ ├── AdminMayorCommands.java │ │ │ │ │ │ └── MayorCommands.java │ │ │ │ │ ├── listeners │ │ │ │ │ │ ├── JoinListener.java │ │ │ │ │ │ ├── PhaseListener.java │ │ │ │ │ │ └── UrneListener.java │ │ │ │ │ ├── managers │ │ │ │ │ │ ├── MayorManager.java │ │ │ │ │ │ ├── NPCManager.java │ │ │ │ │ │ └── PerkManager.java │ │ │ │ │ ├── menu │ │ │ │ │ │ ├── MayorElectionMenu.java │ │ │ │ │ │ ├── MayorLawMenu.java │ │ │ │ │ │ ├── MayorMandateMenu.java │ │ │ │ │ │ ├── MayorVoteMenu.java │ │ │ │ │ │ ├── MoreInfoMenu.java │ │ │ │ │ │ ├── create │ │ │ │ │ │ │ ├── MayorColorMenu.java │ │ │ │ │ │ │ ├── MayorCreateMenu.java │ │ │ │ │ │ │ ├── MayorModifyMenu.java │ │ │ │ │ │ │ ├── MenuType.java │ │ │ │ │ │ │ └── PerkChoiceMenu.java │ │ │ │ │ │ └── npc │ │ │ │ │ │ │ ├── MayorNpcMenu.java │ │ │ │ │ │ │ └── OwnerNpcMenu.java │ │ │ │ │ ├── models │ │ │ │ │ │ ├── CityLaw.java │ │ │ │ │ │ ├── Mayor.java │ │ │ │ │ │ ├── MayorCandidate.java │ │ │ │ │ │ ├── MayorConstant.java │ │ │ │ │ │ └── MayorVote.java │ │ │ │ │ ├── npcs │ │ │ │ │ │ ├── MayorNPC.java │ │ │ │ │ │ └── OwnerNPC.java │ │ │ │ │ └── perks │ │ │ │ │ │ ├── PerkType.java │ │ │ │ │ │ ├── Perks.java │ │ │ │ │ │ ├── basic │ │ │ │ │ │ ├── AyweniterPerk.java │ │ │ │ │ │ ├── CityHunterPerk.java │ │ │ │ │ │ ├── DemonFruitPerk.java │ │ │ │ │ │ ├── GPSTrackerPerk.java │ │ │ │ │ │ ├── IronBloodPerk.java │ │ │ │ │ │ ├── MascotFriendlyPerk.java │ │ │ │ │ │ ├── MinerPerk.java │ │ │ │ │ │ ├── RagePerk.java │ │ │ │ │ │ └── SymbiosisPerk.java │ │ │ │ │ │ ├── event │ │ │ │ │ │ ├── AgriculturalEssorPerk.java │ │ │ │ │ │ ├── IdyllicRain.java │ │ │ │ │ │ ├── ImpotCollection.java │ │ │ │ │ │ ├── MilitaryDissuasion.java │ │ │ │ │ │ └── MineralRushPerk.java │ │ │ │ │ │ └── readme.md │ │ │ │ │ └── war │ │ │ │ │ ├── War.java │ │ │ │ │ ├── WarManager.java │ │ │ │ │ ├── WarPendingDefense.java │ │ │ │ │ ├── actions │ │ │ │ │ └── WarActions.java │ │ │ │ │ ├── commands │ │ │ │ │ ├── AdminWarCommand.java │ │ │ │ │ └── WarCommand.java │ │ │ │ │ ├── listeners │ │ │ │ │ ├── TntPlaceListener.java │ │ │ │ │ └── WarKillListener.java │ │ │ │ │ └── menu │ │ │ │ │ ├── MoreInfoMenu.java │ │ │ │ │ ├── main │ │ │ │ │ ├── MainWarMenu.java │ │ │ │ │ ├── WarCityDetailsMenu.java │ │ │ │ │ └── WarPlayerListMenu.java │ │ │ │ │ └── selection │ │ │ │ │ ├── WarChooseParticipantsMenu.java │ │ │ │ │ └── WarChooseSizeMenu.java │ │ │ ├── contest │ │ │ │ ├── ContestEndEvent.java │ │ │ │ ├── commands │ │ │ │ │ └── ContestCommand.java │ │ │ │ ├── listeners │ │ │ │ │ ├── ContestIntractEvents.java │ │ │ │ │ └── ContestListener.java │ │ │ │ ├── managers │ │ │ │ │ ├── ContestManager.java │ │ │ │ │ └── ContestPlayerManager.java │ │ │ │ ├── menu │ │ │ │ │ ├── ConfirmMenu.java │ │ │ │ │ ├── ContributionMenu.java │ │ │ │ │ ├── MoreInfoMenu.java │ │ │ │ │ ├── TradeMenu.java │ │ │ │ │ └── VoteMenu.java │ │ │ │ └── models │ │ │ │ │ ├── Contest.java │ │ │ │ │ └── ContestPlayer.java │ │ │ ├── corporation │ │ │ │ ├── CorpPermission.java │ │ │ │ ├── ItemsAdderIntegration.java │ │ │ │ ├── MethodState.java │ │ │ │ ├── commands │ │ │ │ │ ├── CompanyCommand.java │ │ │ │ │ └── ShopCommand.java │ │ │ │ ├── company │ │ │ │ │ ├── Company.java │ │ │ │ │ └── CompanyOwner.java │ │ │ │ ├── data │ │ │ │ │ ├── MerchantData.java │ │ │ │ │ └── TransactionData.java │ │ │ │ ├── listener │ │ │ │ │ ├── CustomItemsCompanyListener.java │ │ │ │ │ └── ShopListener.java │ │ │ │ ├── manager │ │ │ │ │ ├── CompanyManager.java │ │ │ │ │ ├── PlayerShopManager.java │ │ │ │ │ └── ShopBlocksManager.java │ │ │ │ ├── menu │ │ │ │ │ ├── company │ │ │ │ │ │ ├── CompanyBaltopMenu.java │ │ │ │ │ │ ├── CompanyBankTransactionsMenu.java │ │ │ │ │ │ ├── CompanyMenu.java │ │ │ │ │ │ ├── CompanySearchMenu.java │ │ │ │ │ │ └── ShopManageMenu.java │ │ │ │ │ └── shop │ │ │ │ │ │ ├── ShopCatalogueMenu.java │ │ │ │ │ │ ├── ShopMenu.java │ │ │ │ │ │ ├── ShopSalesMenu.java │ │ │ │ │ │ ├── ShopSearchMenu.java │ │ │ │ │ │ └── ShopStocksMenu.java │ │ │ │ ├── models │ │ │ │ │ ├── CompanyMerchant.java │ │ │ │ │ ├── CompanyPermission.java │ │ │ │ │ ├── DBCompany.java │ │ │ │ │ ├── DBShop.java │ │ │ │ │ ├── DBShopItem.java │ │ │ │ │ ├── DBShopSale.java │ │ │ │ │ ├── Merchant.java │ │ │ │ │ └── ShopSupplier.java │ │ │ │ └── shops │ │ │ │ │ ├── Shop.java │ │ │ │ │ ├── ShopItem.java │ │ │ │ │ ├── ShopOwner.java │ │ │ │ │ └── Supply.java │ │ │ ├── displays │ │ │ │ ├── TabList.java │ │ │ │ ├── bossbar │ │ │ │ │ ├── BossbarManager.java │ │ │ │ │ ├── BossbarsType.java │ │ │ │ │ ├── commands │ │ │ │ │ │ └── BossBarCommand.java │ │ │ │ │ └── listeners │ │ │ │ │ │ └── BossbarListener.java │ │ │ │ ├── holograms │ │ │ │ │ ├── Hologram.java │ │ │ │ │ ├── HologramInfo.java │ │ │ │ │ ├── HologramLoader.java │ │ │ │ │ └── commands │ │ │ │ │ │ └── HologramCommand.java │ │ │ │ └── scoreboards │ │ │ │ │ ├── GlobalTeamManager.java │ │ │ │ │ ├── ScoreboardCommand.java │ │ │ │ │ ├── ScoreboardListener.java │ │ │ │ │ └── ScoreboardManager.java │ │ │ ├── economy │ │ │ │ ├── BankManager.java │ │ │ │ ├── EconomyManager.java │ │ │ │ ├── Transaction.java │ │ │ │ ├── TransactionsManager.java │ │ │ │ ├── TransactionsMenu.java │ │ │ │ ├── commands │ │ │ │ │ ├── Baltop.java │ │ │ │ │ ├── BankCommands.java │ │ │ │ │ ├── History.java │ │ │ │ │ ├── Money.java │ │ │ │ │ └── Pay.java │ │ │ │ ├── events │ │ │ │ │ └── BankDepositEvent.java │ │ │ │ ├── menu │ │ │ │ │ ├── PersonalBankDepositMenu.java │ │ │ │ │ ├── PersonalBankMenu.java │ │ │ │ │ └── PersonalBankWithdrawMenu.java │ │ │ │ └── models │ │ │ │ │ ├── Bank.java │ │ │ │ │ └── EconomyPlayer.java │ │ │ ├── friend │ │ │ │ ├── Friend.java │ │ │ │ ├── FriendCommand.java │ │ │ │ ├── FriendManager.java │ │ │ │ ├── FriendRequest.java │ │ │ │ └── FriendSQLManager.java │ │ │ ├── homes │ │ │ │ ├── HomeLimits.java │ │ │ │ ├── HomeUpgradeManager.java │ │ │ │ ├── HomesManager.java │ │ │ │ ├── command │ │ │ │ │ ├── DelHome.java │ │ │ │ │ ├── HomeWorld.java │ │ │ │ │ ├── RelocateHome.java │ │ │ │ │ ├── RenameHome.java │ │ │ │ │ ├── SetHome.java │ │ │ │ │ ├── TpHome.java │ │ │ │ │ └── UpgradeHome.java │ │ │ │ ├── events │ │ │ │ │ ├── HomeCreateEvent.java │ │ │ │ │ └── HomeUpgradeEvent.java │ │ │ │ ├── icons │ │ │ │ │ ├── CachedIconItem.java │ │ │ │ │ ├── HomeIcon.java │ │ │ │ │ ├── HomeIconCacheManager.java │ │ │ │ │ ├── HomeIconRegistry.java │ │ │ │ │ ├── IconCategory.java │ │ │ │ │ ├── IconType.java │ │ │ │ │ └── OldHomeIcon.java │ │ │ │ ├── menu │ │ │ │ │ ├── HomeChangeIconMenu.java │ │ │ │ │ ├── HomeConfigMenu.java │ │ │ │ │ ├── HomeDeleteConfirmMenu.java │ │ │ │ │ ├── HomeMenu.java │ │ │ │ │ └── HomeUpgradeMenu.java │ │ │ │ ├── models │ │ │ │ │ ├── Home.java │ │ │ │ │ └── HomeLimit.java │ │ │ │ ├── utils │ │ │ │ │ └── HomeUtil.java │ │ │ │ └── world │ │ │ │ │ ├── DisabledWorldHome.java │ │ │ │ │ └── WorldDisableInfo.java │ │ │ ├── leaderboards │ │ │ │ ├── LeaderboardManager.java │ │ │ │ └── commands │ │ │ │ │ └── LeaderboardCommands.java │ │ │ ├── mailboxes │ │ │ │ ├── Letter.java │ │ │ │ ├── MailboxCommand.java │ │ │ │ ├── MailboxListener.java │ │ │ │ ├── MailboxManager.java │ │ │ │ ├── events │ │ │ │ │ └── ClaimLetterEvent.java │ │ │ │ ├── letter │ │ │ │ │ ├── LetterHead.java │ │ │ │ │ └── SenderLetter.java │ │ │ │ ├── menu │ │ │ │ │ ├── HomeMailbox.java │ │ │ │ │ ├── PendingMailbox.java │ │ │ │ │ ├── PlayerMailbox.java │ │ │ │ │ ├── PlayersList.java │ │ │ │ │ └── letter │ │ │ │ │ │ ├── Letter.java │ │ │ │ │ │ ├── LetterMenu.java │ │ │ │ │ │ └── SendingLetter.java │ │ │ │ └── utils │ │ │ │ │ ├── MailboxInv.java │ │ │ │ │ ├── MailboxMenuManager.java │ │ │ │ │ ├── MailboxUtils.java │ │ │ │ │ └── PaginatedMailbox.java │ │ │ ├── mainmenu │ │ │ │ ├── MainMenu.java │ │ │ │ ├── commands │ │ │ │ │ └── MainMenuCommand.java │ │ │ │ ├── listeners │ │ │ │ │ └── PacketListener.java │ │ │ │ └── menus │ │ │ │ │ ├── Page1.java │ │ │ │ │ └── Page2.java │ │ │ ├── milestones │ │ │ │ ├── Milestone.java │ │ │ │ ├── MilestoneCommand.java │ │ │ │ ├── MilestoneModel.java │ │ │ │ ├── MilestoneType.java │ │ │ │ ├── MilestonesManager.java │ │ │ │ ├── listeners │ │ │ │ │ └── PlayerJoin.java │ │ │ │ ├── menus │ │ │ │ │ ├── MainMilestonesMenu.java │ │ │ │ │ └── MilestoneMenu.java │ │ │ │ └── tutorial │ │ │ │ │ ├── TutorialBossBar.java │ │ │ │ │ ├── TutorialHologram.java │ │ │ │ │ ├── TutorialMilestone.java │ │ │ │ │ ├── TutorialStep.java │ │ │ │ │ ├── listeners │ │ │ │ │ └── TutorialBossBarEvent.java │ │ │ │ │ ├── quests │ │ │ │ │ ├── BreakAyweniteQuest.java │ │ │ │ │ ├── CityCreateQuest.java │ │ │ │ │ ├── ClaimLetterQuest.java │ │ │ │ │ ├── FinishQuestQuest.java │ │ │ │ │ ├── HomeCreateQuest.java │ │ │ │ │ ├── HomeUpgradeQuest.java │ │ │ │ │ ├── OpenAdminShopMenuQuest.java │ │ │ │ │ ├── OpenContestMenuQuest.java │ │ │ │ │ ├── OpenQuestMenuQuest.java │ │ │ │ │ ├── OpenSettingsMenuQuest.java │ │ │ │ │ ├── SellBuyQuest.java │ │ │ │ │ └── SpareBankQuest.java │ │ │ │ │ └── utils │ │ │ │ │ └── TutorialUtils.java │ │ │ ├── privatemessage │ │ │ │ ├── PrivateMessageManager.java │ │ │ │ ├── SocialSpyManager.java │ │ │ │ └── command │ │ │ │ │ ├── PrivateMessageCommand.java │ │ │ │ │ └── SocialSpyCommand.java │ │ │ ├── quests │ │ │ │ ├── QuestProgressSaveManager.java │ │ │ │ ├── QuestsManager.java │ │ │ │ ├── command │ │ │ │ │ └── QuestCommand.java │ │ │ │ ├── events │ │ │ │ │ └── QuestCompleteEvent.java │ │ │ │ ├── menus │ │ │ │ │ └── QuestsMenu.java │ │ │ │ ├── objects │ │ │ │ │ ├── Quest.java │ │ │ │ │ ├── QuestBuilder.java │ │ │ │ │ ├── QuestStep.java │ │ │ │ │ └── QuestTier.java │ │ │ │ ├── quests │ │ │ │ │ ├── BreakDiamondQuest.java │ │ │ │ │ ├── BreakLogQuest.java │ │ │ │ │ ├── BreakStoneQuest.java │ │ │ │ │ ├── BreakWheatQuest.java │ │ │ │ │ ├── ChickenThrowerQuest.java │ │ │ │ │ ├── ConsumeKebabQuest.java │ │ │ │ │ ├── CraftCakeQuest.java │ │ │ │ │ ├── CraftDiamondArmorQuest.java │ │ │ │ │ ├── CraftTheMixtureQuest.java │ │ │ │ │ ├── EnchantFirstItemQuest.java │ │ │ │ │ ├── FishingQuest.java │ │ │ │ │ ├── KillPlayersQuest.java │ │ │ │ │ ├── KillSuperCreeperQuest.java │ │ │ │ │ ├── KillZombieQuest.java │ │ │ │ │ ├── MineAyweniteQuest.java │ │ │ │ │ ├── SaveTheEarthQuest.java │ │ │ │ │ ├── SmeltIronQuest.java │ │ │ │ │ ├── WalkQuests.java │ │ │ │ │ └── WinContestQuest.java │ │ │ │ ├── readme.md │ │ │ │ └── rewards │ │ │ │ │ ├── QuestItemReward.java │ │ │ │ │ ├── QuestMethodsReward.java │ │ │ │ │ ├── QuestMoneyReward.java │ │ │ │ │ ├── QuestReward.java │ │ │ │ │ └── QuestTextReward.java │ │ │ ├── settings │ │ │ │ ├── PlayerSettings.java │ │ │ │ ├── PlayerSettingsManager.java │ │ │ │ ├── SettingType.java │ │ │ │ ├── ValueType.java │ │ │ │ ├── command │ │ │ │ │ └── SettingsCommand.java │ │ │ │ ├── menu │ │ │ │ │ └── PlayerSettingsMenu.java │ │ │ │ ├── models │ │ │ │ │ └── PlayerSettingEntity.java │ │ │ │ └── policy │ │ │ │ │ ├── CityPolicy.java │ │ │ │ │ ├── FriendPolicy.java │ │ │ │ │ ├── GlobalPolicy.java │ │ │ │ │ └── Policy.java │ │ │ ├── tpa │ │ │ │ ├── TPAManager.java │ │ │ │ ├── TPAQueue.java │ │ │ │ └── commands │ │ │ │ │ ├── TPACommand.java │ │ │ │ │ ├── TPAcceptCommand.java │ │ │ │ │ ├── TPCancelCommand.java │ │ │ │ │ └── TPDenyCommand.java │ │ │ └── updates │ │ │ │ ├── UpdateCommand.java │ │ │ │ ├── UpdateListener.java │ │ │ │ └── UpdateManager.java │ │ │ ├── items │ │ │ ├── CustomItem.java │ │ │ ├── CustomItemRegistry.java │ │ │ ├── CustomItemsDebugCommand.java │ │ │ └── usable │ │ │ │ ├── CustomUsableItem.java │ │ │ │ └── CustomUsableItemRegistry.java │ │ │ ├── listeners │ │ │ ├── AsyncChatListener.java │ │ │ ├── ChronometerListener.java │ │ │ ├── ClockInfos.java │ │ │ ├── CubeListener.java │ │ │ ├── InteractListener.java │ │ │ ├── JoinMessageListener.java │ │ │ ├── PlayerDeathListener.java │ │ │ ├── RespawnListener.java │ │ │ ├── SessionsListener.java │ │ │ └── SleepListener.java │ │ │ └── utils │ │ │ ├── CacheOfflinePlayer.java │ │ │ ├── ChunkInfo.java │ │ │ ├── ChunkPos.java │ │ │ ├── ColorUtils.java │ │ │ ├── DateUtils.java │ │ │ ├── DirectionUtils.java │ │ │ ├── DiscordWebhook.java │ │ │ ├── InputUtils.java │ │ │ ├── ItemUtils.java │ │ │ ├── LocationUtils.java │ │ │ ├── MaterialUtils.java │ │ │ ├── MotdUtils.java │ │ │ ├── ParticleUtils.java │ │ │ ├── PlayerNameCache.java │ │ │ ├── PlayerUtils.java │ │ │ ├── Queue.java │ │ │ ├── api │ │ │ ├── FancyNpcsApi.java │ │ │ ├── ItemsAdderApi.java │ │ │ ├── LuckPermsApi.java │ │ │ ├── PapiApi.java │ │ │ └── WorldGuardApi.java │ │ │ ├── customfonts │ │ │ ├── CustomFonts.java │ │ │ └── Fonts.java │ │ │ ├── database │ │ │ └── DatabaseManager.java │ │ │ ├── entities │ │ │ └── TextDisplay.java │ │ │ ├── messages │ │ │ ├── MessageType.java │ │ │ ├── MessagesManager.java │ │ │ └── Prefix.java │ │ │ ├── serializer │ │ │ ├── BukkitSerializer.java │ │ │ └── LocationSerializer.java │ │ │ ├── translation │ │ │ └── TranslationManager.java │ │ │ └── world │ │ │ ├── WorldUtils.java │ │ │ └── Yaw.java │ └── resources │ │ ├── config.yml │ │ ├── data │ │ ├── accountdetection.yml │ │ ├── adminshop.yml │ │ ├── bossbars.yml │ │ ├── contest.yml │ │ ├── leaderboards.yml │ │ ├── mascots.yml │ │ ├── motd.yml │ │ ├── rtp.yml │ │ └── spawn.yml │ │ ├── plugin.yml │ │ └── translations │ │ └── fr.yml └── test │ ├── java │ └── fr │ │ └── openmc │ │ └── core │ │ ├── OMCPluginTest.java │ │ └── utils │ │ ├── DateUtilsTest.java │ │ ├── InputUtilsTest.java │ │ ├── ItemsUtilTest.java │ │ └── MotdUtilsTest.java │ └── resources │ ├── config.yml │ └── plugin.yml └── third_party_licenses └── SignGUI_LICENSE /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Créé un report d'un bug pour nous aider ! 4 | title: "[BUG] " 5 | labels: ":lady_beetle: Bug Report" 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Décrire le bug ?** 11 | _une description claire du bug_ 12 | 13 | **Pour le reproduire** 14 | Étape pour reproduire le Bug 15 | 1. Aller '...' 16 | 2. Cliquer sur '....' 17 | 3. Taper la commande '....' 18 | 19 | **Capture d'écran** 20 | _si possible ajouter des photos du bug_ 21 | 22 | **Informations Supplémentaires :** 23 | - Serveur : [ex. local, production] 24 | Si local alors : 25 | - Plugins : [ex. ItemAdder 4.0.9, ...] 26 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/demande-de-changement-.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: 'Demande de Changement ' 3 | about: 'Demandez un Changement/Amélioration sur une Feature ' 4 | title: "[CHANGE] " 5 | labels: ":arrows_counterclockwise: Changement" 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Le Changement concerne quelle Feature ?** 11 | _veuillez décrire, dire quelle feature (ex. La Banque de la Ville, Les Trades des Contests, ...)_ 12 | 13 | **Description du Changement** 14 | _veuillez donner une description précise (ex. Réduire le cooldown entre la navigation de 2 menu, ...)_ 15 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/demande-de-feature.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Demande de Feature 3 | about: Suggérer une idée pour OpenMC ! 4 | title: "[FEAT]" 5 | labels: ":package: Features" 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Décrire votre Feature que vous voulez demander** 11 | _Une bonne description qui décrit tout ce que vous voulez_ 12 | 13 | **Capture d'écran** 14 | _des photos de GUI, pour bien de mob, de lore_ 15 | 16 | **Voulez vous faire cette feature ? :** 17 | -------------------------------------------------------------------------------- /.github/issue_template.md: -------------------------------------------------------------------------------- 1 | ## Pour que votre Issue soit accepté, il vous faut : 2 | * Quel Type d'Issue (bug, feature, ...) : 3 | 4 | ## Decrivez vos changements 5 | *Clairement et avec des screenshots si nécessaires* -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | ## Petit résumé de la PR: 2 | 3 | 4 | ## Étape nécessaire afin que la PR soit fini (si PR en draft) 5 | 6 | 7 | 8 | - [ ] Suivre le [Code de Conduite](https://github.com/ServerOpenMC/PluginV2/blob/master/CODE_OF_CONDUCT.md) 9 | - [ ] Enlever tous les imports non utilisés 10 | - [ ] Bien documenter la feature 11 | - [ ] Fournir un profileur (si besoin/demandé par un admin) 12 | - [ ] Avoir une milestone associée à la PR 13 | - [ ] Valider tout les checks 14 | - [ ] Tester et valider la feature/changement 15 | 16 | * Les Issues corrigée(s) en commun : 17 | 18 | ## Decrivez vos changements 19 | 20 | -------------------------------------------------------------------------------- /.github/release.yml: -------------------------------------------------------------------------------- 1 | changelog: 2 | categories: 3 | - title: Nouvelles Fonctionnalités 4 | labels: 5 | - "🆙 Amélioration" 6 | - ":arrows_counterclockwise: Changement" 7 | - ":package: Features" 8 | - title: Bugs et Optimisations 9 | labels: 10 | - "⚡Optimisation" 11 | - ":sparkles: Fixes" 12 | - title: Autre 13 | labels: 14 | - "*" 15 | -------------------------------------------------------------------------------- /.github/workflows/check-milestone.yml: -------------------------------------------------------------------------------- 1 | name: Milestone Check 2 | 3 | on: 4 | pull_request: 5 | types: [opened, edited, reopened, synchronize] 6 | 7 | jobs: 8 | check-milestone: 9 | name: Milestone check 10 | runs-on: ubuntu-latest 11 | steps: 12 | - name: Verify that PR has been assigned a milestone 13 | run: | 14 | if [ "${{ github.event.pull_request.milestone }}" == "" ]; then 15 | echo "❌ PR has not been assigned a milestone." 16 | exit 1 17 | fi 18 | -------------------------------------------------------------------------------- /.github/workflows/release-to-discord.yml: -------------------------------------------------------------------------------- 1 | name: Release to Discord 2 | on: 3 | release: 4 | types: [published] 5 | 6 | jobs: 7 | github-releases-to-discord: 8 | runs-on: ubuntu-latest 9 | name: Release to Discord 10 | steps: 11 | - name: Checkout 12 | uses: actions/checkout@v4 13 | - name: Github Releases To Discord 14 | uses: SethCohen/github-releases-to-discord@v1.16.2 15 | with: 16 | webhook_url: ${{ secrets.WEBHOOK_URL }} 17 | color: "16021398" # decimal of #f47796 18 | username: "Mise à jour de OpenMC" 19 | avatar_url: "https://raw.githubusercontent.com/ServerOpenMC/.github/refs/heads/master/brandkit/logo.png" 20 | #content: "||<@&1258420105209974804>||" 21 | footer_title: "Changements" 22 | footer_icon_url: "https://raw.githubusercontent.com/ServerOpenMC/.github/refs/heads/master/brandkit/logo.png" 23 | footer_timestamp: true 24 | max_description: '16384' 25 | reduce_headings: true 26 | -------------------------------------------------------------------------------- /.github/workflows/tag-sync.yml: -------------------------------------------------------------------------------- 1 | name: Sync Tags from Upstream 2 | 3 | on: 4 | push: 5 | workflow_dispatch: 6 | schedule: 7 | - cron: '0 0 * * *' # Runs at 00:00 UTC every day 8 | 9 | jobs: 10 | sync-tags: 11 | if: github.repository != 'ServerOpenMC/PluginV2' 12 | runs-on: ubuntu-latest 13 | steps: 14 | - name: Checkout repository 15 | uses: actions/checkout@v4 16 | with: 17 | fetch-depth: 0 18 | token: ${{ secrets.GITHUB_TOKEN }} 19 | 20 | - name: Configure Git 21 | run: | 22 | git config user.name "GitHub Actions" 23 | git config user.email "actions@github.com" 24 | 25 | - name: Sync tags from upstream 26 | run: | 27 | git remote add upstream https://github.com/ServerOpenMC/PluginV2.git 28 | git fetch upstream --tags 29 | git push origin --tags 30 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Plugin OpenMC 2 | Nouveau plugin collaboratif pour un serveur : VOTRE serveur ! 3 | 4 | 5 | 6 | 7 | 8 | ## 🤝 Rejoindre le développement. 9 | 1. Commencez par forker le dépôt et rejoindre le [Discord](https://discord.gg/aywen) 10 | 2. Assurez-vous de bien suivre [CONTRIBUTING.md](https://github.com/ServerOpenMC/PluginV2/blob/master/CONTRIBUTING.md) 11 | 3. Une fois qu'une fonctionnalité est implémentée et fonctionnelle, créez une pull request. 12 | 4. Après approbation, elle sera disponible sur le serveur de développement pour les tests. 13 | 14 | Serveur de test : `dev.openmc.fr` (1.21.5 Java Edition) 15 | 16 | Serveur de la beta : `beta.openmc.fr` (1.21.5 Java Edition) 17 | 18 | Serveur de jeu : `play.openmc.fr` (1.21.5 Java Edition) 19 | 20 | ## 📘 En apprendre plus. 21 | Vous voulez en savoir plus ? Vous voulez avoir des tutoriels à propos d'OpenMC ? 22 | Cliquez [ici](https://github.com/ServerOpenMC/PluginV2/wiki) afin d'accéder au wiki 23 | 24 | ## 📃 License 25 | Projet sous [GPL-3.0 license](https://choosealicense.com/licenses/gpl-3.0/). 26 | 27 | ## Crédits 28 | Ce projet intègre du code provenant de la repo [SignGUI](https://github.com/Rapha149/SignGUI), spécifiquement de la [Pull Request #30](https://github.com/Rapha149/SignGUI/pull/30) pour la mise à jour de compatibilité avec Minecraft 1.21.5. 29 | La repo originale est sous licence [MIT](https://github.com/Rapha149/SignGUI/blob/main/LICENSE). 30 | 31 | --- 32 | Merci à @MathiasDPX pour la nouvelle configuration du repo. 33 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServerOpenMC/PluginV2/4444690a752419f1e60d23ccf297aaf1ce11de8a/gradle.properties -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServerOpenMC/PluginV2/4444690a752419f1e60d23ccf297aaf1ce11de8a/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip 4 | networkTimeout=10000 5 | validateDistributionUrl=true 6 | zipStoreBase=GRADLE_USER_HOME 7 | zipStorePath=wrapper/dists -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'OpenMC' 2 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/api/chronometer/ChronometerInfo.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.api.chronometer; 2 | 3 | import lombok.Getter; 4 | 5 | 6 | @Getter 7 | public class ChronometerInfo { 8 | private final String chronometerGroup; 9 | private final int chronometerTime; 10 | 11 | public ChronometerInfo(String chronometerGroup, int chronometerTime) { 12 | this.chronometerTime = chronometerTime; 13 | this.chronometerGroup = chronometerGroup; 14 | } 15 | } -------------------------------------------------------------------------------- /src/main/java/fr/openmc/api/chronometer/ChronometerType.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.api.chronometer; 2 | 3 | import lombok.Getter; 4 | import net.md_5.bungee.api.ChatMessageType; 5 | 6 | @Getter 7 | public enum ChronometerType { 8 | ACTION_BAR(ChatMessageType.ACTION_BAR), 9 | CHAT(ChatMessageType.CHAT), 10 | SYSTEM(ChatMessageType.SYSTEM); 11 | 12 | private final ChatMessageType chatMessageType; 13 | 14 | ChronometerType(ChatMessageType chatMessageType) { 15 | if (chatMessageType==null){ 16 | chatMessageType = ChatMessageType.SYSTEM; 17 | } 18 | this.chatMessageType = chatMessageType; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/api/cooldown/CooldownEndEvent.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.api.cooldown; 2 | 3 | import lombok.Getter; 4 | import org.bukkit.event.Event; 5 | import org.bukkit.event.HandlerList; 6 | 7 | public class CooldownEndEvent extends Event { 8 | private static final HandlerList HANDLERS = new HandlerList(); 9 | private final String uuid; 10 | @Getter 11 | private final String group; 12 | 13 | public CooldownEndEvent(String uuid, String group) { 14 | this.uuid = uuid; 15 | this.group = group; 16 | } 17 | 18 | public String getUUID() { 19 | return uuid; 20 | } 21 | 22 | @Override 23 | public HandlerList getHandlers() { 24 | return HANDLERS; 25 | } 26 | 27 | public static HandlerList getHandlerList() { 28 | return HANDLERS; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/api/cooldown/CooldownInterceptor.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.api.cooldown; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | import org.jetbrains.annotations.Unmodifiable; 5 | import revxrsal.commands.command.CommandActor; 6 | import revxrsal.commands.command.ExecutableCommand; 7 | import revxrsal.commands.process.CommandCondition; 8 | 9 | import java.util.List; 10 | 11 | public class CooldownInterceptor implements CommandCondition { 12 | @Override 13 | public void test(@NotNull CommandActor actor, @NotNull ExecutableCommand command, @NotNull @Unmodifiable List arguments) { 14 | 15 | DynamicCooldown cooldown = command.getAnnotation(DynamicCooldown.class); 16 | if (cooldown == null) { 17 | return; 18 | } 19 | 20 | if (!DynamicCooldownManager.isReady(actor.getUniqueId().toString(), cooldown.group())) { 21 | long remaining = DynamicCooldownManager.getRemaining(actor.getUniqueId().toString(), cooldown.group()); 22 | String message = cooldown.message(); 23 | message = message.replace("%sec%", String.valueOf(remaining / 1000)); 24 | message = message.replace("%ms%", String.valueOf(remaining)); 25 | actor.reply(message); 26 | throw new IllegalStateException("Cooldown active"); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/api/cooldown/CooldownStartEvent.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.api.cooldown; 2 | 3 | import lombok.Getter; 4 | import org.bukkit.event.Event; 5 | import org.bukkit.event.HandlerList; 6 | 7 | public class CooldownStartEvent extends Event { 8 | private static final HandlerList HANDLERS = new HandlerList(); 9 | private final String uuid; 10 | @Getter 11 | private final String group; 12 | 13 | public CooldownStartEvent(String uuid, String group) { 14 | this.uuid = uuid; 15 | this.group = group; 16 | } 17 | 18 | public String getUUID() { 19 | return uuid; 20 | } 21 | 22 | @Override 23 | public HandlerList getHandlers() { 24 | return HANDLERS; 25 | } 26 | 27 | public static HandlerList getHandlerList() { 28 | return HANDLERS; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/api/cooldown/DynamicCooldown.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.api.cooldown; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Target(ElementType.METHOD) 9 | @Retention(RetentionPolicy.RUNTIME) 10 | public @interface DynamicCooldown { 11 | /** 12 | * The cooldown group name 13 | * 14 | * @return group name 15 | */ 16 | String group() default "general"; 17 | 18 | /** 19 | * The message to show when cooldown is active 20 | * 21 | * @return message 22 | */ 23 | String message() default "§cVous devez attendre %sec%s"; 24 | /* 25 | * %sec% | Le temps restant en secondes 26 | * %ms% | Le temps restant en millisecondes 27 | */ 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/api/input/ChatInput.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.api.input; 2 | 3 | import io.papermc.paper.event.player.AsyncChatEvent; 4 | import net.kyori.adventure.text.TextComponent; 5 | import org.bukkit.entity.Player; 6 | import org.bukkit.event.EventHandler; 7 | import org.bukkit.event.Listener; 8 | 9 | import java.util.HashMap; 10 | import java.util.Map; 11 | import java.util.UUID; 12 | import java.util.function.Consumer; 13 | 14 | public class ChatInput implements Listener { 15 | 16 | private static final Map> playerInputs = new HashMap<>(); 17 | 18 | public static void sendInput(Player player, String startMessage, Consumer callback) { 19 | playerInputs.put(player.getUniqueId(), callback); 20 | player.closeInventory(); 21 | player.sendMessage(startMessage); 22 | } 23 | 24 | @EventHandler 25 | public void onPlayerChat(AsyncChatEvent event) { 26 | Player player = event.getPlayer(); 27 | if (playerInputs.containsKey(player.getUniqueId())) { 28 | event.setCancelled(true); 29 | 30 | Consumer callback = playerInputs.remove(player.getUniqueId()); 31 | 32 | if (event.message() instanceof TextComponent textComponent) { 33 | String string = textComponent.content(); 34 | if (string.contains("cancel")) { 35 | player.sendMessage("§eVous avez annulé l'action !"); 36 | callback.accept(null); 37 | } 38 | callback.accept(string); 39 | } 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/api/input/location/InteractionInfo.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.api.input.location; 2 | 3 | import fr.openmc.api.chronometer.ChronometerInfo; 4 | import lombok.Getter; 5 | import org.bukkit.inventory.ItemStack; 6 | 7 | @Getter 8 | public class InteractionInfo { 9 | private final ItemStack item; 10 | private final ChronometerInfo chronometerInfo; 11 | 12 | public InteractionInfo(ItemStack item, ChronometerInfo chronometerInfo) { 13 | this.chronometerInfo = chronometerInfo; 14 | this.item = item; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/api/input/signgui/SignEditor.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.api.input.signgui; 2 | 3 | import io.netty.channel.ChannelPipeline; 4 | import org.bukkit.Location; 5 | 6 | // Ce code est basé sur le fichier SignEditor.java du dépôt SignGUI 7 | // (https://github.com/Rapha149/SignGUI). Licence originale : MIT. 8 | public class SignEditor { 9 | 10 | private final Object sign; 11 | private final Location location; 12 | private final Object blockPosition; 13 | private final ChannelPipeline pipeline; 14 | 15 | public SignEditor(Object sign, Location location, Object blockPosition, ChannelPipeline pipeline) { 16 | this.sign = sign; 17 | this.location = location; 18 | this.blockPosition = blockPosition; 19 | this.pipeline = pipeline; 20 | } 21 | 22 | public Object getSign() { 23 | return sign; 24 | } 25 | 26 | public Location getLocation() { 27 | return location; 28 | } 29 | 30 | public Object getBlockPosition() { 31 | return blockPosition; 32 | } 33 | 34 | public ChannelPipeline getPipeline() { 35 | return pipeline; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/api/input/signgui/SignGUIChannelHandler.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.api.input.signgui; 2 | 3 | import io.netty.handler.codec.MessageToMessageDecoder; 4 | 5 | // Ce code est basé sur le fichier SignGUIChannelHandler.java du dépôt SignGUI 6 | // (https://github.com/Rapha149/SignGUI). Licence originale : MIT. 7 | public abstract class SignGUIChannelHandler extends MessageToMessageDecoder { 8 | 9 | public abstract Object getBlockPosition(); 10 | 11 | public abstract void close(); 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/api/input/signgui/SignGUIFinishHandler.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.api.input.signgui; 2 | 3 | import org.bukkit.entity.Player; 4 | 5 | import java.util.List; 6 | 7 | // Ce code est basé sur le fichier SignGUIFinishHandler.java du dépôt SignGUI 8 | // (https://github.com/Rapha149/SignGUI). Licence originale : MIT. 9 | /** 10 | * A functional interface used for handling the result of the sign editing. 11 | */ 12 | @FunctionalInterface 13 | public interface SignGUIFinishHandler { 14 | 15 | /** 16 | * Called when the player finished editing the sign. 17 | * Return a list of actions that should be executed after the editing is finished. The actions are executed in the order they are in the list. 18 | * If {@link SignGUIAction#displayNewLines(String...)} is not included, the sign gui will be closed. 19 | * If you just want to close the sign gui, return an empty list or null. 20 | * 21 | * @param player The player who edited the sign. 22 | * @param result The result of the editing. 23 | * @return The list of actions. 24 | */ 25 | List onFinish(Player player, SignGUIResult result); 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/api/input/signgui/exception/SignGUIException.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.api.input.signgui.exception; 2 | 3 | // Ce code est basé sur le fichier SignGUIException.java du dépôt SignGUI 4 | // (https://github.com/Rapha149/SignGUI). Licence originale : MIT. 5 | /** 6 | * An exception thrown when an error occurs while using this api. 7 | */ 8 | public class SignGUIException extends RuntimeException { 9 | 10 | /** 11 | * {@inheritDoc} 12 | */ 13 | public SignGUIException() { 14 | } 15 | 16 | /** 17 | * {@inheritDoc} 18 | */ 19 | public SignGUIException(String message) { 20 | super(message); 21 | } 22 | 23 | /** 24 | * {@inheritDoc} 25 | */ 26 | public SignGUIException(String message, Throwable cause) { 27 | super(message, cause); 28 | } 29 | 30 | /** 31 | * {@inheritDoc} 32 | */ 33 | public SignGUIException(Throwable cause) { 34 | super(cause); 35 | } 36 | 37 | /** 38 | * {@inheritDoc} 39 | */ 40 | public SignGUIException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { 41 | super(message, cause, enableSuppression, writableStackTrace); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/api/input/signgui/exception/SignGUIVersionException.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.api.input.signgui.exception; 2 | 3 | // Ce code est basé sur le fichier SignGUIVersionException.java du dépôt SignGUI 4 | // (https://github.com/Rapha149/SignGUI). Licence originale : MIT. 5 | /** 6 | * An exception thrown when the server version is not supported by this api or an error occured during initialization. 7 | */ 8 | public class SignGUIVersionException extends Exception { 9 | 10 | /** 11 | * {@inheritDoc} 12 | */ 13 | public SignGUIVersionException() { 14 | } 15 | 16 | /** 17 | * {@inheritDoc} 18 | */ 19 | public SignGUIVersionException(String message) { 20 | super(message); 21 | } 22 | 23 | /** 24 | * {@inheritDoc} 25 | */ 26 | public SignGUIVersionException(String message, Throwable cause) { 27 | super(message, cause); 28 | } 29 | 30 | /** 31 | * {@inheritDoc} 32 | */ 33 | public SignGUIVersionException(Throwable cause) { 34 | super(cause); 35 | } 36 | 37 | /** 38 | * {@inheritDoc} 39 | */ 40 | public SignGUIVersionException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { 41 | super(message, cause, enableSuppression, writableStackTrace); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/api/menulib/utils/InventorySize.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.api.menulib.utils; 2 | 3 | import lombok.Getter; 4 | 5 | /** 6 | * Represents different inventory sizes that can be used for organizing game inventories. 7 | * Each inventory size is associated with a specific numerical value representing the 8 | * number of slots available in the inventory. 9 | *

10 | * This enum provides a convenient way to define and manage various inventory sizes:
11 | * - {@code SMALLEST}: 9 slots
12 | * - {@code SMALL}: 18 slots
13 | * - {@code NORMAL}: 27 slots
14 | * - {@code LARGE}: 36 slots
15 | * - {@code LARGER}: 45 slots
16 | * - {@code LARGEST}: 54 slots
17 | */ 18 | public enum InventorySize { 19 | 20 | SMALLEST(9), 21 | SMALL(18), 22 | NORMAL(27), 23 | LARGE(36), 24 | LARGER(45), 25 | LARGEST(54); 26 | 27 | @Getter 28 | private final int size; 29 | 30 | /** 31 | * Constructs an InventorySize enum instance with the specified size. 32 | * 33 | * @param size the size of the inventory associated with this enum instance 34 | */ 35 | InventorySize(int size) { 36 | this.size = size; 37 | } 38 | } -------------------------------------------------------------------------------- /src/main/java/fr/openmc/api/packetmenulib/events/InventoryClickEvent.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.api.packetmenulib.events; 2 | 3 | import fr.openmc.api.packetmenulib.menu.ClickType; 4 | import org.bukkit.entity.Player; 5 | 6 | public record InventoryClickEvent(ClickType clickType, int slot, Player player) { 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/api/packetmenulib/events/InventoryCloseEvent.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.api.packetmenulib.events; 2 | 3 | import org.bukkit.entity.Player; 4 | 5 | public record InventoryCloseEvent(Player player) { 6 | } 7 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/api/packetmenulib/menu/ClickType.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.api.packetmenulib.menu; 2 | 3 | public enum ClickType { 4 | LEFT_CLICK, 5 | RIGHT_CLICK, 6 | SHIFT_LEFT_CLICK, 7 | SHIFT_RIGHT_CLICK, 8 | DOUBLE_CLICK, 9 | CLICK_OUTSIDE, 10 | OTHER // We find the other buttons inconvenient for users, and we won’t ask a player to press a keyboard key just to click a button. 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/api/packetmenulib/menu/Menu.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.api.packetmenulib.menu; 2 | 3 | import fr.openmc.api.packetmenulib.events.InventoryClickEvent; 4 | import fr.openmc.api.packetmenulib.events.InventoryCloseEvent; 5 | import net.kyori.adventure.text.Component; 6 | import org.bukkit.inventory.ItemStack; 7 | 8 | import java.util.Map; 9 | 10 | /** 11 | * Voir https://minecraft.wiki/w/Java_Edition_protocol/Inventory#Windows 12 | */ 13 | public interface Menu { 14 | Component getTitle(); 15 | InventoryType getInventoryType(); 16 | Map getContent(); 17 | void onInventoryClick(InventoryClickEvent inventoryClickEvent); 18 | void onInventoryClose(InventoryCloseEvent inventoryCloseEvent); 19 | boolean isCursorItemEnabled(); 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/commands/admin/freeze/FreezeCommand.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.commands.admin.freeze; 2 | 3 | import org.bukkit.entity.Player; 4 | import revxrsal.commands.annotation.Command; 5 | import revxrsal.commands.annotation.Named; 6 | import revxrsal.commands.bukkit.annotation.CommandPermission; 7 | 8 | public class FreezeCommand { 9 | 10 | /** 11 | * Freeze a player 12 | * 13 | * @param player The player who executes the command 14 | * @param target The target player to freeze 15 | */ 16 | @Command("freeze") 17 | @CommandPermission("omc.admins.commands.freeze") 18 | public void onCommand(Player player, @Named("player") Player target) { 19 | FreezeManager.switchFreeze(player, target); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/commands/debug/CooldownCommand.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.commands.debug; 2 | 3 | import fr.openmc.api.cooldown.DynamicCooldown; 4 | import fr.openmc.api.cooldown.DynamicCooldownManager; 5 | import net.kyori.adventure.text.Component; 6 | import net.kyori.adventure.text.format.NamedTextColor; 7 | import org.bukkit.entity.Player; 8 | import revxrsal.commands.annotation.AutoComplete; 9 | import revxrsal.commands.annotation.Command; 10 | import revxrsal.commands.annotation.Description; 11 | import revxrsal.commands.annotation.Named; 12 | import revxrsal.commands.bukkit.annotation.CommandPermission; 13 | 14 | public class CooldownCommand { 15 | @Command("debug cooldown") 16 | @CommandPermission("omc.debug.cooldown") 17 | @AutoComplete("success|error") 18 | @Description("Test de cooldown") 19 | @DynamicCooldown(group="test", message = "§c%ms% (%sec%s)") 20 | public void cooldown(Player player, @Named("isSuccess") String isSuccess) { 21 | if (isSuccess.equals("success")) { 22 | player.sendMessage(Component.text("Succès, le cooldown est activé").color(NamedTextColor.GREEN)); 23 | DynamicCooldownManager.use(player.getUniqueId().toString(), "test" ,5000); 24 | } else { 25 | player.sendMessage(Component.text("Erreur, vous pouvez refaire la commande").color(NamedTextColor.RED)); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/commands/fun/Diceroll.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.commands.fun; 2 | 3 | import java.util.Random; 4 | 5 | import fr.openmc.core.utils.messages.MessageType; 6 | import fr.openmc.core.utils.messages.MessagesManager; 7 | import fr.openmc.core.utils.messages.Prefix; 8 | import net.kyori.adventure.text.Component; 9 | import org.bukkit.entity.Player; 10 | import revxrsal.commands.annotation.Command; 11 | import revxrsal.commands.annotation.Description; 12 | import revxrsal.commands.bukkit.annotation.CommandPermission; 13 | 14 | public class Diceroll { 15 | @Command("diceroll") 16 | @CommandPermission("omc.commands.diceroll") 17 | @Description("Faire un lancé de dés (Donne un nombre aléatoire entre 1 et 10)") 18 | private void diceroll(Player player) { 19 | Random rand = new Random(); 20 | int result = rand.nextInt(10) + 1; 21 | 22 | 23 | MessagesManager.sendMessage(player, Component.text("🎲 Le résultat est: §6" + result + "§r 🎲"), Prefix.OPENMC, MessageType.INFO, true); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/commands/fun/Playtime.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.commands.fun; 2 | 3 | import fr.openmc.core.utils.DateUtils; 4 | import fr.openmc.core.utils.messages.MessageType; 5 | import fr.openmc.core.utils.messages.MessagesManager; 6 | import fr.openmc.core.utils.messages.Prefix; 7 | import fr.openmc.core.utils.translation.TranslationManager; 8 | import net.kyori.adventure.text.Component; 9 | import org.bukkit.Statistic; 10 | import org.bukkit.entity.Player; 11 | import revxrsal.commands.annotation.Command; 12 | import revxrsal.commands.annotation.Description; 13 | import revxrsal.commands.bukkit.annotation.CommandPermission; 14 | 15 | public class Playtime { 16 | @Command("playtime") 17 | @CommandPermission("omc.commands.playtime") 18 | @Description("Donne votre temps de jeu") 19 | private void playtime(Player player) { 20 | long timePlayed = player.getStatistic(Statistic.PLAY_ONE_MINUTE); 21 | 22 | MessagesManager.sendMessage(player, Component.text(TranslationManager.getTranslation("messages.general.playtime", 23 | "fr", "playTime", DateUtils.convertTime(timePlayed))), Prefix.OPENMC, MessageType.INFO, true); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/commands/utils/SetSpawn.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.commands.utils; 2 | 3 | import net.kyori.adventure.text.Component; 4 | import org.bukkit.Location; 5 | import org.bukkit.entity.Player; 6 | 7 | import fr.openmc.core.utils.messages.MessageType; 8 | import fr.openmc.core.utils.messages.MessagesManager; 9 | import fr.openmc.core.utils.messages.Prefix; 10 | import revxrsal.commands.annotation.Command; 11 | import revxrsal.commands.annotation.Description; 12 | import revxrsal.commands.bukkit.annotation.CommandPermission; 13 | 14 | public class SetSpawn { 15 | 16 | @Command("setspawn") 17 | @Description("Permet de changer le spawn") 18 | @CommandPermission("omc.admin.commands.setspawn") 19 | public void setSpawn(Player player) { 20 | 21 | Location location = player.getLocation(); 22 | 23 | SpawnManager.setSpawn(location); 24 | 25 | MessagesManager.sendMessage(player, Component.text("§aVous avez changé le point de spawn en §6X: §e" + location.getBlockX() + "§6, Y:§e" + location.getBlockY() + "§6, Z: §e" + location.getBlockY()), Prefix.OPENMC, MessageType.SUCCESS, true); 26 | 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/adminshop/AdminShopCommand.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.adminshop; 2 | 3 | import org.bukkit.entity.Player; 4 | import revxrsal.commands.annotation.Command; 5 | import revxrsal.commands.annotation.Description; 6 | 7 | 8 | public class AdminShopCommand { 9 | @Command("adminshop") 10 | @Description("Ouvrir le menu du shop admin") 11 | public void openAdminShop(Player player) { 12 | AdminShopManager.openMainMenu(player); 13 | } 14 | } -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/adminshop/ShopCategory.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.adminshop; 2 | 3 | import org.bukkit.Material; 4 | 5 | public record ShopCategory(String id, String name, Material material, int position) {} -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/adminshop/events/BuyEvent.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.adminshop.events; 2 | 3 | import fr.openmc.core.features.adminshop.ShopItem; 4 | import lombok.Getter; 5 | import org.bukkit.entity.Player; 6 | import org.bukkit.event.Event; 7 | import org.bukkit.event.HandlerList; 8 | import org.jetbrains.annotations.NotNull; 9 | 10 | @Getter 11 | public class BuyEvent extends Event { 12 | 13 | private final ShopItem item; 14 | private final Player player; 15 | 16 | private static final HandlerList HANDLERS = new HandlerList(); 17 | 18 | public BuyEvent(Player player, ShopItem item) { 19 | this.player = player; 20 | this.item = item; 21 | 22 | } 23 | 24 | public static HandlerList getHandlerList() { 25 | return HANDLERS; 26 | } 27 | 28 | @Override 29 | public @NotNull HandlerList getHandlers() { 30 | return HANDLERS; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/adminshop/events/SellEvent.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.adminshop.events; 2 | 3 | import fr.openmc.core.features.adminshop.ShopItem; 4 | import lombok.Getter; 5 | import org.bukkit.entity.Player; 6 | import org.bukkit.event.Event; 7 | import org.bukkit.event.HandlerList; 8 | import org.jetbrains.annotations.NotNull; 9 | 10 | @Getter 11 | public class SellEvent extends Event { 12 | 13 | private final ShopItem item; 14 | private final Player player; 15 | 16 | private static final HandlerList HANDLERS = new HandlerList(); 17 | 18 | public SellEvent(Player player, ShopItem item) { 19 | this.player = player; 20 | this.item = item; 21 | } 22 | 23 | public static HandlerList getHandlerList() { 24 | return HANDLERS; 25 | } 26 | 27 | @Override 28 | public @NotNull HandlerList getHandlers() { 29 | return HANDLERS; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/analytics/Stats.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.analytics; 2 | 3 | import java.util.UUID; 4 | 5 | public enum Stats { 6 | SESSION("session"), 7 | TOTAL_TRANSACTIONS("total_transactions"), 8 | ; 9 | 10 | private String scope; 11 | 12 | Stats(String scope) { 13 | this.scope = scope; 14 | } 15 | 16 | /** 17 | * Return the stats for a player 18 | * 19 | * @param playerUUID Player 20 | * @param defaultValue The value if the analytics manager is disabled 21 | * @return The stats of the player, if unavailable, it will return `0` 22 | */ 23 | public int get(UUID playerUUID, int defaultValue) { 24 | return AnalyticsManager.getStatistic(this.scope, playerUUID, defaultValue); 25 | } 26 | 27 | /** 28 | * Return the stats for a player 29 | * 30 | * @param playerUUID Player 31 | * @return The stats of the player, if unavailable, it will return `0` 32 | */ 33 | public int get(UUID playerUUID) { 34 | return get(playerUUID, 0); 35 | } 36 | 37 | /** 38 | * Increment a stat by one for a player 39 | * 40 | * @param playerUUID Player 41 | * @param value the amount to increment the statistic 42 | */ 43 | public void increment(UUID playerUUID, int value) { 44 | AnalyticsManager.incrementStatistic(this.scope, playerUUID, value); 45 | } 46 | 47 | /** 48 | * Increment a stat by one for a player 49 | * 50 | * @param playerUUID Player 51 | */ 52 | public void increment(UUID playerUUID) { 53 | increment(playerUUID, 1); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/analytics/models/Statistic.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.analytics.models; 2 | 3 | import java.util.UUID; 4 | 5 | import com.j256.ormlite.field.DatabaseField; 6 | import com.j256.ormlite.table.DatabaseTable; 7 | 8 | import lombok.Getter; 9 | 10 | @DatabaseTable(tableName = "stats") 11 | public class Statistic { 12 | @DatabaseField(canBeNull = false, uniqueCombo = true) 13 | private UUID player; 14 | @DatabaseField(canBeNull = false, uniqueCombo = true) 15 | private String scope; 16 | @Getter 17 | @DatabaseField(defaultValue = "0") 18 | private int value; 19 | 20 | Statistic() { 21 | // required for ORMLite 22 | } 23 | 24 | public Statistic(UUID player, String scope, int value) { 25 | this.player = player; 26 | this.scope = scope; 27 | this.value = value; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/city/CPermission.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.city; 2 | 3 | import lombok.Getter; 4 | 5 | public enum CPermission { 6 | OWNER("Propriétaire"), //Impossible à donner sauf avec un transfert 7 | INVITE("Inviter"), 8 | KICK("Expulser"), 9 | CLAIM("Claim"), 10 | SEE_CHUNKS("Voir les Claims"), 11 | RENAME("Renommer"), 12 | MONEY_GIVE("Donner de l'argent"), 13 | MONEY_BALANCE("Voir l'argent"), 14 | MONEY_TAKE("Prendre de l'argent"), 15 | PERMS("Permissions"), // Cette permission est donnée seulement par l'owner 16 | CHEST("Accès au Coffre"), 17 | CHEST_UPGRADE("Améliorer le coffre"), 18 | TYPE("Changer le type de ville"), 19 | MASCOT_MOVE("Déplacer la mascotte"), 20 | MASCOT_SKIN("Changer le skin de la mascotte"), 21 | MASCOT_UPGRADE("Améliorer la mascotte"), 22 | MASCOT_HEAL("Soigner la mascotte"), 23 | LAUNCH_WAR("Lancer des guerres") 24 | ; 25 | 26 | @Getter 27 | private final String displayName; 28 | 29 | CPermission(String displayName) { 30 | this.displayName = displayName; 31 | } 32 | } -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/city/ChunkDataCache.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.city; 2 | 3 | import fr.openmc.core.utils.ChunkInfo; 4 | import fr.openmc.core.utils.ChunkPos; 5 | 6 | import java.util.Map; 7 | 8 | public class ChunkDataCache { 9 | public static final long CACHE_EXPIRY_MS = 30000; // 30 seconds 10 | public final Map chunkInfoMap; 11 | final long timestamp; 12 | 13 | public ChunkDataCache(Map chunkInfoMap) { 14 | this.chunkInfoMap = chunkInfoMap; 15 | this.timestamp = System.currentTimeMillis(); 16 | } 17 | 18 | public boolean isExpired() { 19 | return System.currentTimeMillis() - timestamp > CACHE_EXPIRY_MS; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/city/CityType.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.city; 2 | 3 | public enum CityType { 4 | WAR, 5 | PEACE, 6 | } 7 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/city/actions/CityChestAction.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.city.actions; 2 | 3 | import fr.openmc.core.features.city.City; 4 | import fr.openmc.core.features.city.conditions.CityChestConditions; 5 | import fr.openmc.core.utils.ItemUtils; 6 | import fr.openmc.core.items.CustomItemRegistry; 7 | import fr.openmc.core.utils.messages.MessageType; 8 | import fr.openmc.core.utils.messages.MessagesManager; 9 | import fr.openmc.core.utils.messages.Prefix; 10 | import net.kyori.adventure.text.Component; 11 | import org.bukkit.entity.Player; 12 | 13 | import java.util.Objects; 14 | 15 | import static fr.openmc.core.features.city.conditions.CityChestConditions.UPGRADE_PER_AYWENITE; 16 | import static fr.openmc.core.features.city.conditions.CityChestConditions.UPGRADE_PER_MONEY; 17 | 18 | public class CityChestAction { 19 | 20 | public static void upgradeChest(Player player, City city) { 21 | if (!CityChestConditions.canCityChestUpgrade(city, player)) return; 22 | 23 | int price = city.getChestPages() * UPGRADE_PER_MONEY; 24 | int aywenite = city.getChestPages() * UPGRADE_PER_AYWENITE; 25 | 26 | city.updateBalance((double) -price); 27 | 28 | if (ItemUtils.takeAywenite(player, aywenite)) { 29 | city.saveChestContent(city.getChestPages() + 1, null); 30 | MessagesManager.sendMessage(player, Component.text("Le coffre a été amélioré"), Prefix.CITY, MessageType.SUCCESS, true); 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/city/actions/CityKickAction.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.city.actions; 2 | 3 | import fr.openmc.core.features.city.City; 4 | import fr.openmc.core.features.city.CityManager; 5 | import fr.openmc.core.features.city.conditions.CityKickCondition; 6 | import fr.openmc.core.utils.messages.MessageType; 7 | import fr.openmc.core.utils.messages.MessagesManager; 8 | import fr.openmc.core.utils.messages.Prefix; 9 | import net.kyori.adventure.text.Component; 10 | import org.bukkit.OfflinePlayer; 11 | import org.bukkit.entity.Player; 12 | 13 | 14 | public class CityKickAction { 15 | public static void startKick(Player sender, OfflinePlayer playerKick) { 16 | City city = CityManager.getPlayerCity(sender.getUniqueId()); 17 | 18 | if (!CityKickCondition.canCityKickPlayer(city, sender, playerKick)) return; 19 | 20 | if (city == null) return; 21 | 22 | city.removePlayer(playerKick.getUniqueId()); 23 | MessagesManager.sendMessage(sender, Component.text("Tu as exclu " + playerKick.getName() + " de la ville " + city.getName()), Prefix.CITY, MessageType.SUCCESS, false); 24 | 25 | if (playerKick.isOnline()) { 26 | MessagesManager.sendMessage((Player) playerKick, Component.text("Tu as été exclu de la ville " + city.getName()), Prefix.CITY, MessageType.INFO, true); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/city/actions/CityLeaveAction.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.city.actions; 2 | 3 | import fr.openmc.core.features.city.City; 4 | import fr.openmc.core.features.city.CityManager; 5 | import fr.openmc.core.features.city.conditions.CityLeaveCondition; 6 | import fr.openmc.core.utils.messages.MessageType; 7 | import fr.openmc.core.utils.messages.MessagesManager; 8 | import fr.openmc.core.utils.messages.Prefix; 9 | import net.kyori.adventure.text.Component; 10 | import org.bukkit.Bukkit; 11 | import org.bukkit.entity.Player; 12 | 13 | 14 | public class CityLeaveAction { 15 | 16 | public static void startLeave(Player player) { 17 | City city = CityManager.getPlayerCity(player.getUniqueId()); 18 | 19 | if (city == null) return; 20 | 21 | if (!CityLeaveCondition.canCityLeave(city, player)) return; 22 | 23 | city.removePlayer(player.getUniqueId()); 24 | 25 | MessagesManager.sendMessage(player, Component.text("Tu as quitté " + city.getName()), Prefix.CITY, MessageType.SUCCESS, false); 26 | 27 | city.getOnlineMembers().forEach(memberUUID -> { 28 | if (memberUUID.equals(player.getUniqueId())) return; 29 | Player onlineMember = Bukkit.getPlayer(memberUUID); 30 | MessagesManager.sendMessage(onlineMember, Component.text(player.getName() + " a quitté la ville " + city.getName()), Prefix.CITY, MessageType.INFO, true); 31 | }); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/city/commands/CityChatCommand.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.city.commands; 2 | 3 | import fr.openmc.core.features.city.CityChatManager; 4 | import org.bukkit.entity.Player; 5 | import revxrsal.commands.annotation.Command; 6 | import revxrsal.commands.annotation.Description; 7 | import revxrsal.commands.bukkit.annotation.CommandPermission; 8 | 9 | public class CityChatCommand { 10 | @Command({"cc", "city chat", "ville chat"}) 11 | @CommandPermission("omc.commands.city.chat") 12 | @Description("Activer ou désactiver le chat de ville") 13 | public void onCityChat(Player sender) { 14 | if (!CityChatManager.isCityChatMember(sender)) { 15 | CityChatManager.addCityChatMember(sender); 16 | } else { 17 | CityChatManager.removeCityChatMember(sender); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/city/commands/CityChestCommand.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.city.commands; 2 | 3 | import fr.openmc.core.features.city.City; 4 | import fr.openmc.core.features.city.CityManager; 5 | import fr.openmc.core.features.city.actions.CityChestAction; 6 | import fr.openmc.core.features.city.conditions.CityChestConditions; 7 | import fr.openmc.core.features.city.menu.CityChestMenu; 8 | import org.bukkit.entity.Player; 9 | import revxrsal.commands.annotation.*; 10 | import revxrsal.commands.bukkit.annotation.CommandPermission; 11 | 12 | public class CityChestCommand { 13 | @Command({"city chest", "ville coffre"}) 14 | @Description("Ouvre le coffre de la ville") 15 | @CommandPermission("omc.commands.city.chest") 16 | void chest(Player player, @Optional @Named("page") @Range(min=0) Integer page) { 17 | City city = CityManager.getPlayerCity(player.getUniqueId()); 18 | 19 | if (!CityChestConditions.canCityChestOpen(city, player)) return; 20 | 21 | if ((page == null)) page = 1; 22 | if (page < 1) page = 1; 23 | if (page > city.getChestPages()) page = city.getChestPages(); 24 | 25 | new CityChestMenu(player, city, page).open(); 26 | } 27 | 28 | @Command({"city upgradechest", "ville upgradecoffre"}) 29 | @Description("Améliore la coffre de la ville") 30 | @CommandPermission("omc.commands.city.chest_upgrade") 31 | void upgrade(Player player) { 32 | City city = CityManager.getPlayerCity(player.getUniqueId()); 33 | if (!CityChestConditions.canCityChestUpgrade(city, player)) return; 34 | 35 | CityChestAction.upgradeChest(player, city); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/city/conditions/CityClaimCondition.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.city.conditions; 2 | 3 | import fr.openmc.core.features.city.CPermission; 4 | import fr.openmc.core.features.city.City; 5 | import fr.openmc.core.utils.messages.MessageType; 6 | import fr.openmc.core.utils.messages.MessagesManager; 7 | import fr.openmc.core.utils.messages.Prefix; 8 | import net.kyori.adventure.text.Component; 9 | import org.bukkit.Bukkit; 10 | import org.bukkit.entity.Player; 11 | 12 | /** 13 | * Le but de cette classe est de regrouper toutes les conditions necessaires 14 | * pour claim une zone (utile pour faire une modif sur menu et commandes). 15 | */ 16 | public class CityClaimCondition { 17 | 18 | /** 19 | * Retourne un booleen pour dire si la ville peut etre etendu 20 | * 21 | * @param city la ville sur laquelle on fait les actions 22 | * @param player le joueur sur lequel tester les permissions 23 | * @return booleen 24 | */ 25 | public static boolean canCityClaim(City city, Player player) { 26 | if (player.getWorld() != Bukkit.getWorld("world")) return false ; 27 | 28 | if (city == null) { 29 | MessagesManager.sendMessage(player, MessagesManager.Message.PLAYERNOCITY.getMessage(), Prefix.CITY, MessageType.ERROR, false); 30 | return false; 31 | } 32 | 33 | if (!(city.hasPermission(player.getUniqueId(), CPermission.CLAIM))) { 34 | MessagesManager.sendMessage(player, Component.text("Tu n'as pas la permission de claim"), Prefix.CITY, MessageType.ERROR, false); 35 | return false; 36 | } 37 | 38 | return true; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/city/conditions/CityLeaveCondition.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.city.conditions; 2 | 3 | import fr.openmc.core.features.city.CPermission; 4 | import fr.openmc.core.features.city.City; 5 | import fr.openmc.core.utils.messages.MessageType; 6 | import fr.openmc.core.utils.messages.MessagesManager; 7 | import fr.openmc.core.utils.messages.Prefix; 8 | import net.kyori.adventure.text.Component; 9 | import org.bukkit.entity.Player; 10 | 11 | /** 12 | * Le but de cette classe est de regrouper toutes les conditions necessaires 13 | * pour quitter une ville (utile pour faire une modif sur menu et commandes). 14 | */ 15 | public class CityLeaveCondition { 16 | 17 | /** 18 | * Retourne un booleen pour dire si le joueur peut quitter 19 | * 20 | * @param city la ville sur laquelle on veut quitter 21 | * @param player le joueur qui veut quitter 22 | * @return booleen 23 | */ 24 | public static boolean canCityLeave(City city, Player player) { 25 | if (city == null) { 26 | MessagesManager.sendMessage(player, MessagesManager.Message.PLAYERNOCITY.getMessage(), Prefix.CITY, MessageType.ERROR, false); 27 | return false; 28 | } 29 | 30 | if (city.hasPermission(player.getUniqueId(), CPermission.OWNER)) { 31 | MessagesManager.sendMessage(player, Component.text("Tu ne peux pas quitter la ville car tu en es le maire, supprime la ou transfère la propriété"), Prefix.CITY, MessageType.ERROR, false); 32 | return false; 33 | } 34 | return true; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/city/conditions/CityUnclaimCondition.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.city.conditions; 2 | 3 | import fr.openmc.core.features.city.CPermission; 4 | import fr.openmc.core.features.city.City; 5 | import fr.openmc.core.utils.messages.MessageType; 6 | import fr.openmc.core.utils.messages.MessagesManager; 7 | import fr.openmc.core.utils.messages.Prefix; 8 | import net.kyori.adventure.text.Component; 9 | import org.bukkit.Bukkit; 10 | import org.bukkit.entity.Player; 11 | 12 | /** 13 | * Le but de cette classe est de regrouper toutes les conditions necessaires 14 | * pour unclaim une zone (utile pour faire une modif sur menu et commandes). 15 | */ 16 | public class CityUnclaimCondition { 17 | 18 | /** 19 | * Retourne un booleen pour dire si la ville peut etre retrécie ou non. 20 | * 21 | * @param city la ville sur laquelle on fait les actions 22 | * @param player le joueur sur lequel tester les permissions 23 | * @return booleen 24 | */ 25 | public static boolean canCityUnclaim(City city, Player player) { 26 | if (player.getWorld() != Bukkit.getWorld("world")) return false; 27 | 28 | if (city == null) { 29 | MessagesManager.sendMessage(player, MessagesManager.Message.PLAYERNOCITY.getMessage(), Prefix.CITY, MessageType.ERROR, false); 30 | return false; 31 | } 32 | 33 | if (!(city.hasPermission(player.getUniqueId(), CPermission.CLAIM))) { 34 | MessagesManager.sendMessage(player, Component.text("Tu n'as pas la permission de unclaim"), Prefix.CITY, MessageType.ERROR, false); 35 | return false; 36 | } 37 | 38 | return true; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/city/events/CityCreationEvent.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.city.events; 2 | 3 | import fr.openmc.core.features.city.City; 4 | import lombok.Getter; 5 | import org.bukkit.entity.Player; 6 | import org.bukkit.event.Event; 7 | import org.bukkit.event.HandlerList; 8 | import org.jetbrains.annotations.NotNull; 9 | 10 | @Getter 11 | public class CityCreationEvent extends Event { 12 | 13 | private final City city; 14 | private final Player owner; 15 | 16 | private static final HandlerList HANDLERS = new HandlerList(); 17 | 18 | public CityCreationEvent(City city, Player owner) { 19 | this.city = city; 20 | this.owner = owner; 21 | } 22 | 23 | public static HandlerList getHandlerList() { 24 | return HANDLERS; 25 | } 26 | 27 | @Override 28 | public @NotNull HandlerList getHandlers() { 29 | return HANDLERS; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/city/events/CityDeleteEvent.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.city.events; 2 | 3 | import fr.openmc.core.features.city.City; 4 | import lombok.Getter; 5 | import org.bukkit.event.Event; 6 | import org.bukkit.event.HandlerList; 7 | import org.jetbrains.annotations.NotNull; 8 | 9 | @Getter 10 | public class CityDeleteEvent extends Event { 11 | 12 | private final City city; 13 | 14 | public CityDeleteEvent(City city) { 15 | this.city = city; 16 | } 17 | 18 | private static final HandlerList HANDLERS = new HandlerList(); 19 | 20 | public static HandlerList getHandlerList() { 21 | return HANDLERS; 22 | } 23 | 24 | @Override 25 | public @NotNull HandlerList getHandlers() { 26 | return HANDLERS; 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/city/events/CityMoneyUpdateEvent.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.city.events; 2 | 3 | import fr.openmc.core.features.city.City; 4 | import lombok.Getter; 5 | import org.bukkit.event.Event; 6 | import org.bukkit.event.HandlerList; 7 | import org.jetbrains.annotations.NotNull; 8 | 9 | @Getter 10 | public class CityMoneyUpdateEvent extends Event { 11 | 12 | private static final HandlerList HANDLERS = new HandlerList(); 13 | 14 | private final double difference; 15 | private final double before; 16 | private final double after; 17 | private final City city; 18 | 19 | public CityMoneyUpdateEvent(City city, double before, double after) { 20 | this.city = city; 21 | this.before = before; 22 | this.after = after; 23 | this.difference = after - before; 24 | } 25 | 26 | public static HandlerList getHandlerList() { 27 | return HANDLERS; 28 | } 29 | 30 | @Override 31 | public @NotNull HandlerList getHandlers() { 32 | return HANDLERS; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/city/events/CityPermissionChangeEvent.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.city.events; 2 | 3 | import fr.openmc.core.features.city.CPermission; 4 | import fr.openmc.core.features.city.City; 5 | import lombok.Getter; 6 | import org.bukkit.OfflinePlayer; 7 | import org.bukkit.event.Event; 8 | import org.bukkit.event.HandlerList; 9 | import org.jetbrains.annotations.NotNull; 10 | 11 | @Getter 12 | public class CityPermissionChangeEvent extends Event { 13 | 14 | private final City city; 15 | private final OfflinePlayer member; 16 | private final CPermission permission; 17 | private final boolean value; 18 | 19 | private static final HandlerList HANDLERS = new HandlerList(); 20 | 21 | public CityPermissionChangeEvent(City city, OfflinePlayer member, CPermission permission, boolean value) { 22 | this.city = city; 23 | this.member = member; 24 | this.permission = permission; 25 | this.value = value; 26 | } 27 | 28 | public static HandlerList getHandlerList() { 29 | return HANDLERS; 30 | } 31 | 32 | @Override 33 | public @NotNull HandlerList getHandlers() { 34 | return HANDLERS; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/city/events/CityRenameEvent.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.city.events; 2 | 3 | import fr.openmc.core.features.city.City; 4 | import lombok.Getter; 5 | import org.bukkit.event.Event; 6 | import org.bukkit.event.HandlerList; 7 | import org.jetbrains.annotations.NotNull; 8 | 9 | @Getter 10 | public class CityRenameEvent extends Event { 11 | 12 | private final String oldName; 13 | private final City city; 14 | 15 | public CityRenameEvent(String oldName, City city) { 16 | this.oldName = oldName; 17 | this.city = city; 18 | } 19 | 20 | private static final HandlerList HANDLERS = new HandlerList(); 21 | 22 | public static HandlerList getHandlerList() { 23 | return HANDLERS; 24 | } 25 | 26 | @Override 27 | public @NotNull HandlerList getHandlers() { 28 | return HANDLERS; 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/city/events/MemberJoinEvent.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.city.events; 2 | 3 | import fr.openmc.core.features.city.City; 4 | import lombok.Getter; 5 | import org.bukkit.OfflinePlayer; 6 | import org.bukkit.event.Event; 7 | import org.bukkit.event.HandlerList; 8 | import org.jetbrains.annotations.NotNull; 9 | 10 | @Getter 11 | public class MemberJoinEvent extends Event { 12 | 13 | private final OfflinePlayer player; 14 | private final City city; 15 | 16 | public MemberJoinEvent(OfflinePlayer player, City city) { 17 | this.player = player; 18 | this.city = city; 19 | } 20 | 21 | private static final HandlerList HANDLERS = new HandlerList(); 22 | 23 | public static HandlerList getHandlerList() { 24 | return HANDLERS; 25 | } 26 | 27 | @Override 28 | public @NotNull HandlerList getHandlers() { 29 | return HANDLERS; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/city/events/MemberLeaveEvent.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.city.events; 2 | 3 | import fr.openmc.core.features.city.City; 4 | import lombok.Getter; 5 | import org.bukkit.OfflinePlayer; 6 | import org.bukkit.event.Event; 7 | import org.bukkit.event.HandlerList; 8 | import org.jetbrains.annotations.NotNull; 9 | 10 | @Getter 11 | public class MemberLeaveEvent extends Event { 12 | private final OfflinePlayer player; 13 | private final City city; 14 | 15 | public MemberLeaveEvent(OfflinePlayer player, City city) { 16 | this.player = player; 17 | this.city = city; 18 | } 19 | 20 | private static final HandlerList HANDLERS = new HandlerList(); 21 | 22 | public static HandlerList getHandlerList() { 23 | return HANDLERS; 24 | } 25 | 26 | @Override 27 | public @NotNull HandlerList getHandlers() { 28 | return HANDLERS; 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/city/listeners/CityChatListener.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.city.listeners; 2 | 3 | import fr.openmc.core.features.city.CityChatManager; 4 | import io.papermc.paper.event.player.AsyncChatEvent; 5 | import net.kyori.adventure.text.Component; 6 | import org.bukkit.entity.Player; 7 | import org.bukkit.event.EventHandler; 8 | import org.bukkit.event.Listener; 9 | 10 | public class CityChatListener implements Listener { 11 | 12 | @EventHandler 13 | public void onPlayerChat(AsyncChatEvent event) { 14 | Player player = event.getPlayer(); 15 | Component message = event.message(); 16 | 17 | if (CityChatManager.isCityChatMember(player)) { 18 | event.setCancelled(true); 19 | CityChatManager.sendCityChatMessage(player, message); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/city/listeners/protections/BlockProtection.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.city.listeners.protections; 2 | 3 | import fr.openmc.core.features.city.ProtectionsManager; 4 | import org.bukkit.Material; 5 | import org.bukkit.event.EventHandler; 6 | import org.bukkit.event.Listener; 7 | import org.bukkit.event.block.BlockBreakEvent; 8 | import org.bukkit.event.block.BlockPlaceEvent; 9 | 10 | public class BlockProtection implements Listener { 11 | @EventHandler 12 | public void onPlaceBlock(BlockPlaceEvent event) { 13 | if (event.getBlock().getType() == Material.TNT) return; // used in city.sub.war.listener.TntPlaceListener.java 14 | 15 | ProtectionsManager.verify(event.getPlayer(), event, event.getBlock().getLocation()); 16 | } 17 | 18 | @EventHandler 19 | void onBlockBreak(BlockBreakEvent event) { 20 | ProtectionsManager.verify(event.getPlayer(), event, event.getBlock().getLocation()); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/city/listeners/protections/BowProtection.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.city.listeners.protections; 2 | 3 | import com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent; 4 | import fr.openmc.core.features.city.ProtectionsManager; 5 | import org.bukkit.GameMode; 6 | import org.bukkit.entity.Player; 7 | import org.bukkit.event.EventHandler; 8 | import org.bukkit.event.Listener; 9 | import org.bukkit.event.entity.EntityShootBowEvent; 10 | 11 | public class BowProtection implements Listener { 12 | @EventHandler 13 | void onLaunchProjectile(PlayerLaunchProjectileEvent event) { 14 | ProtectionsManager.verify(event.getPlayer(), event, event.getPlayer().getLocation()); 15 | } 16 | 17 | @EventHandler 18 | public void onEntityShootBow(EntityShootBowEvent event) { 19 | if (!(event.getEntity() instanceof Player player)) return; 20 | 21 | ProtectionsManager.verify(player, event, event.getEntity().getLocation()); 22 | 23 | if (event.isCancelled() && !player.getGameMode().equals(GameMode.CREATIVE)) { 24 | player.getInventory().addItem(event.getConsumable()); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/city/listeners/protections/CityExplosionData.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.city.listeners.protections; 2 | 3 | import lombok.Getter; 4 | 5 | public class CityExplosionData { 6 | @Getter 7 | private int explosions; 8 | private long lastResetTimestamp; 9 | 10 | public CityExplosionData() { 11 | this.explosions = 0; 12 | this.lastResetTimestamp = System.currentTimeMillis(); 13 | } 14 | 15 | public void resetIfNeeded() { 16 | long now = System.currentTimeMillis(); 17 | if (now - lastResetTimestamp >= 86_400_000L) { // 24h 18 | explosions = 0; 19 | lastResetTimestamp = now; 20 | } 21 | } 22 | 23 | public boolean canExplode(int maxPerDay) { 24 | resetIfNeeded(); 25 | return explosions < maxPerDay; 26 | } 27 | 28 | public void increment() { 29 | explosions++; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/city/listeners/protections/EntityProtection.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.city.listeners.protections; 2 | 3 | import fr.openmc.core.features.city.ProtectionsManager; 4 | import org.bukkit.entity.Entity; 5 | import org.bukkit.entity.Player; 6 | import org.bukkit.event.EventHandler; 7 | import org.bukkit.event.Listener; 8 | import org.bukkit.event.player.PlayerArmorStandManipulateEvent; 9 | import org.bukkit.event.player.PlayerInteractEntityEvent; 10 | import org.bukkit.event.player.PlayerShearEntityEvent; 11 | import org.bukkit.inventory.InventoryHolder; 12 | import org.bukkit.inventory.Merchant; 13 | 14 | public class EntityProtection implements Listener { 15 | @EventHandler 16 | public void onArmorStandManipulate(PlayerArmorStandManipulateEvent event) { 17 | ProtectionsManager.verify(event.getPlayer(), event, event.getRightClicked().getLocation()); 18 | } 19 | 20 | @EventHandler 21 | void onShear(PlayerShearEntityEvent event) { 22 | ProtectionsManager.verify(event.getPlayer(), event, event.getEntity().getLocation()); 23 | } 24 | 25 | @EventHandler 26 | public void onEntityInventoryOpen(PlayerInteractEntityEvent event) { 27 | Player player = event.getPlayer(); 28 | Entity entity = event.getRightClicked(); 29 | 30 | if (entity instanceof Merchant || entity instanceof InventoryHolder) { 31 | ProtectionsManager.verify(player, event, entity.getLocation()); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/city/listeners/protections/FireProtection.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.city.listeners.protections; 2 | 3 | 4 | import fr.openmc.core.features.city.ProtectionsManager; 5 | import org.bukkit.Location; 6 | import org.bukkit.entity.Player; 7 | import org.bukkit.event.EventHandler; 8 | import org.bukkit.event.Listener; 9 | import org.bukkit.event.block.BlockIgniteEvent; 10 | 11 | public class FireProtection implements Listener { 12 | @EventHandler 13 | public void onFireIgnite(BlockIgniteEvent event) { 14 | Location loc = event.getBlock().getLocation(); 15 | Player player = event.getPlayer(); 16 | 17 | if (player == null) return; 18 | 19 | ProtectionsManager.verify(event.getPlayer(), event, loc); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/city/listeners/protections/FishProtection.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.city.listeners.protections; 2 | 3 | import fr.openmc.core.features.city.ProtectionsManager; 4 | import org.bukkit.event.EventHandler; 5 | import org.bukkit.event.Listener; 6 | import org.bukkit.event.player.PlayerFishEvent; 7 | 8 | public class FishProtection implements Listener { 9 | @EventHandler 10 | void onFish(PlayerFishEvent event) { 11 | ProtectionsManager.verify(event.getPlayer(), event, event.getHook().getLocation()); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/city/listeners/protections/FoodProtection.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.city.listeners.protections; 2 | 3 | import org.bukkit.event.EventHandler; 4 | import org.bukkit.event.EventPriority; 5 | import org.bukkit.event.Listener; 6 | import org.bukkit.event.player.PlayerItemConsumeEvent; 7 | 8 | public class FoodProtection implements Listener { 9 | @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) 10 | public void onFoodConsume(PlayerItemConsumeEvent event) { 11 | // on laisse les gens manger 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/city/listeners/protections/HangingProtection.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.city.listeners.protections; 2 | 3 | import fr.openmc.core.features.city.ProtectionsManager; 4 | import org.bukkit.entity.*; 5 | import org.bukkit.event.EventHandler; 6 | import org.bukkit.event.Listener; 7 | import org.bukkit.event.hanging.HangingBreakByEntityEvent; 8 | import org.bukkit.event.player.PlayerInteractEntityEvent; 9 | 10 | public class HangingProtection implements Listener { 11 | @EventHandler 12 | public void onPlayerInteractEntity(PlayerInteractEntityEvent event) { 13 | if (event.isCancelled()) return; 14 | 15 | Player player = event.getPlayer(); 16 | Entity entity = event.getRightClicked(); 17 | 18 | if (entity instanceof ItemFrame || entity instanceof GlowItemFrame || entity instanceof Hanging) { 19 | ProtectionsManager.verify(player, event, entity.getLocation()); 20 | } 21 | } 22 | 23 | @EventHandler 24 | public void onHangingBreakByEntity(HangingBreakByEntityEvent event) { 25 | if (event.isCancelled()) return; 26 | if (event.getRemover() instanceof Player player) { 27 | ProtectionsManager.verify(player, event, event.getEntity().getLocation()); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/city/listeners/protections/LeashProtection.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.city.listeners.protections; 2 | 3 | import fr.openmc.core.features.city.ProtectionsManager; 4 | import org.bukkit.event.EventHandler; 5 | import org.bukkit.event.Listener; 6 | import org.bukkit.event.entity.PlayerLeashEntityEvent; 7 | import org.bukkit.event.player.PlayerUnleashEntityEvent; 8 | 9 | public class LeashProtection implements Listener { 10 | @EventHandler 11 | void onLeash(PlayerLeashEntityEvent event) { 12 | ProtectionsManager.verify(event.getPlayer(), event, event.getEntity().getLocation()); 13 | } 14 | 15 | @EventHandler 16 | void onUnleash(PlayerUnleashEntityEvent event) { 17 | ProtectionsManager.verify(event.getPlayer(), event, event.getEntity().getLocation()); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/city/listeners/protections/MountProtection.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.city.listeners.protections; 2 | 3 | import fr.openmc.core.features.city.ProtectionsManager; 4 | import org.bukkit.entity.Entity; 5 | import org.bukkit.entity.Player; 6 | import org.bukkit.entity.Tameable; 7 | import org.bukkit.event.EventHandler; 8 | import org.bukkit.event.Listener; 9 | import org.bukkit.event.entity.EntityMountEvent; 10 | 11 | public class MountProtection implements Listener { 12 | @EventHandler 13 | public void onEntityMount(EntityMountEvent event) { 14 | if (event.isCancelled()) return; 15 | if (!(event.getEntity() instanceof Player player)) return; 16 | 17 | Entity mount = event.getMount(); 18 | 19 | if (!(mount instanceof Tameable tameable)) return; 20 | 21 | 22 | if (!tameable.isTamed()) return; 23 | 24 | if (tameable.getOwnerUniqueId() == null) { 25 | ProtectionsManager.verify(player, event, mount.getLocation()); 26 | return; 27 | } 28 | 29 | if (!tameable.getOwnerUniqueId().equals(player.getUniqueId())) 30 | ProtectionsManager.verify(player, event, mount.getLocation()); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/city/listeners/protections/TramplingProtection.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.city.listeners.protections; 2 | 3 | import fr.openmc.core.features.city.ProtectionsManager; 4 | import org.bukkit.Material; 5 | import org.bukkit.block.Block; 6 | import org.bukkit.event.EventHandler; 7 | import org.bukkit.event.Listener; 8 | import org.bukkit.event.block.Action; 9 | import org.bukkit.event.entity.EntityInteractEvent; 10 | import org.bukkit.event.player.PlayerInteractEvent; 11 | 12 | public class TramplingProtection implements Listener { 13 | @EventHandler 14 | public void onEntityInteract(EntityInteractEvent event) { 15 | if (event.isCancelled()) return; 16 | Block block = event.getBlock(); 17 | if (block.getType() == Material.FARMLAND) { 18 | ProtectionsManager.verify(event.getEntity(), event, block.getLocation()); 19 | } 20 | } 21 | 22 | @EventHandler 23 | public void onPlayerTrampling(PlayerInteractEvent event) { 24 | if (event.isCancelled()) return; 25 | if (event.getAction() == Action.PHYSICAL) { 26 | if (event.getClickedBlock() == null) return; 27 | if (event.getClickedBlock().getType() == Material.FARMLAND) { 28 | ProtectionsManager.verify(event.getPlayer(), event, event.getClickedBlock().getLocation()); 29 | } 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/city/models/DBCity.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.city.models; 2 | 3 | import com.j256.ormlite.field.DatabaseField; 4 | import com.j256.ormlite.table.DatabaseTable; 5 | import fr.openmc.core.features.city.City; 6 | import lombok.Getter; 7 | 8 | @DatabaseTable(tableName = "cities") 9 | public class DBCity { 10 | @DatabaseField(id = true, columnName = "uuid") 11 | @Getter 12 | private String UUID; 13 | @DatabaseField 14 | private String name; 15 | @DatabaseField(defaultValue = "0") 16 | private double balance; 17 | @DatabaseField(canBeNull = false) 18 | private String type; 19 | @DatabaseField(canBeNull = false) 20 | private int power; 21 | @DatabaseField(canBeNull = false, columnName = "free_claims") 22 | private int freeClaims; 23 | 24 | DBCity() { 25 | // required for ORMLite 26 | } 27 | 28 | public DBCity(String uuid, String name, double balance, String type, int power, int freeClaims) { 29 | this.UUID = uuid; 30 | this.name = name; 31 | this.balance = balance; 32 | this.type = type; 33 | this.power = power; 34 | this.freeClaims = freeClaims; 35 | } 36 | 37 | public City deserialize() { 38 | return new City(UUID, name, balance, type, power, freeClaims); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/city/models/DBCityChest.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.city.models; 2 | 3 | import org.bukkit.inventory.ItemStack; 4 | 5 | import com.j256.ormlite.field.DataType; 6 | import com.j256.ormlite.field.DatabaseField; 7 | import com.j256.ormlite.table.DatabaseTable; 8 | 9 | import fr.openmc.core.utils.serializer.BukkitSerializer; 10 | import lombok.Getter; 11 | 12 | @DatabaseTable(tableName = "city_chests") 13 | public class DBCityChest { 14 | @DatabaseField(canBeNull = false) 15 | private String city; 16 | @DatabaseField(canBeNull = false) 17 | @Getter 18 | private int page; 19 | @DatabaseField(canBeNull = false, dataType = DataType.BYTE_ARRAY) 20 | private byte[] content; 21 | 22 | DBCityChest() { 23 | // required for ORMLite 24 | } 25 | 26 | public DBCityChest(String city, int page, ItemStack[] content) { 27 | this.city = city; 28 | this.page = page; 29 | 30 | try { 31 | this.content = BukkitSerializer.serializeItemStacks(content); 32 | } catch (Exception e) { 33 | e.printStackTrace(); 34 | } 35 | } 36 | 37 | public ItemStack[] getContent() { 38 | try { 39 | return BukkitSerializer.deserializeItemStacks(content); 40 | } catch (Exception e) { 41 | e.printStackTrace(); 42 | return null; 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/city/models/DBCityClaim.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.city.models; 2 | 3 | import com.j256.ormlite.field.DatabaseField; 4 | import com.j256.ormlite.table.DatabaseTable; 5 | import com.sk89q.worldedit.math.BlockVector2; 6 | 7 | import lombok.Getter; 8 | 9 | @DatabaseTable(tableName = "city_regions") 10 | public class DBCityClaim { 11 | @DatabaseField(canBeNull = false) 12 | @Getter 13 | private String city; 14 | @DatabaseField(canBeNull = false) 15 | private int x; 16 | @DatabaseField(canBeNull = false) 17 | private int z; 18 | 19 | DBCityClaim() { 20 | // required for ORMLite 21 | } 22 | 23 | public DBCityClaim(BlockVector2 chunk, String city) { 24 | this.city = city; 25 | this.x = chunk.getX(); 26 | this.z = chunk.getZ(); 27 | } 28 | 29 | public BlockVector2 getBlockVector() { 30 | return BlockVector2.at(x, z); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/city/models/DBCityMember.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.city.models; 2 | 3 | import java.util.UUID; 4 | 5 | import com.j256.ormlite.field.DatabaseField; 6 | import com.j256.ormlite.table.DatabaseTable; 7 | 8 | import lombok.Getter; 9 | 10 | @DatabaseTable(tableName = "city_members") 11 | public class DBCityMember { 12 | @DatabaseField(id = true) 13 | @Getter 14 | private UUID player; 15 | @DatabaseField(canBeNull = false) 16 | @Getter 17 | private String city; 18 | 19 | DBCityMember() { 20 | // required for ORMLite 21 | } 22 | 23 | public DBCityMember(UUID player, String city) { 24 | this.player = player; 25 | this.city = city; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/city/models/DBCityPermission.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.city.models; 2 | 3 | import java.util.UUID; 4 | 5 | import com.j256.ormlite.field.DatabaseField; 6 | import com.j256.ormlite.table.DatabaseTable; 7 | 8 | import fr.openmc.core.features.city.CPermission; 9 | import lombok.Getter; 10 | 11 | @DatabaseTable(tableName = "city_permissions") 12 | public class DBCityPermission { 13 | @DatabaseField(canBeNull = false) 14 | private String city; 15 | @DatabaseField(canBeNull = false, uniqueCombo = true) 16 | @Getter 17 | private UUID player; 18 | @DatabaseField(canBeNull = false, uniqueCombo = true) 19 | private String permission; 20 | 21 | DBCityPermission() { 22 | // required for ORMLite 23 | } 24 | 25 | public DBCityPermission(String city, UUID player, String permission) { 26 | this.city = city; 27 | this.player = player; 28 | this.permission = permission; 29 | } 30 | 31 | public CPermission getPermission() { 32 | return CPermission.valueOf(permission); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/city/sub/bank/CityBankManager.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.city.sub.bank; 2 | 3 | import fr.openmc.core.CommandsManager; 4 | import fr.openmc.core.features.city.CityManager; 5 | import fr.openmc.core.features.city.sub.bank.commands.CityBankCommand; 6 | 7 | import java.sql.SQLException; 8 | import java.util.List; 9 | 10 | 11 | public class CityBankManager { 12 | 13 | public CityBankManager() { 14 | 15 | CommandsManager.getHandler().register( 16 | new CityBankCommand() 17 | ); 18 | } 19 | 20 | /** 21 | * Apply all city interests 22 | * WARNING: THIS FUNCTION IS VERY EXPENSIVE DO NOT RUN FREQUENTLY IT WILL AFFECT PERFORMANCE IF THERE ARE MANY CITIES SAVED IN THE DB 23 | */ 24 | public static void applyAllCityInterests() { 25 | try { 26 | List cityUUIDs = CityManager.getAllCityUUIDs(); 27 | for (String cityUUID : cityUUIDs) { 28 | CityManager.getCity(cityUUID).applyCityInterest(); 29 | } 30 | } catch (SQLException e) { 31 | throw new RuntimeException(e); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/city/sub/mascots/commands/AdminMascotsCommands.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.city.sub.mascots.commands; 2 | 3 | import fr.openmc.core.features.city.City; 4 | import fr.openmc.core.features.city.CityManager; 5 | import fr.openmc.core.features.city.sub.mascots.MascotsManager; 6 | import fr.openmc.core.utils.messages.MessageType; 7 | import fr.openmc.core.utils.messages.MessagesManager; 8 | import fr.openmc.core.utils.messages.Prefix; 9 | import net.kyori.adventure.text.Component; 10 | import org.bukkit.entity.Player; 11 | import revxrsal.commands.annotation.Command; 12 | import revxrsal.commands.annotation.Named; 13 | import revxrsal.commands.annotation.Subcommand; 14 | import revxrsal.commands.bukkit.annotation.CommandPermission; 15 | 16 | import java.sql.SQLException; 17 | 18 | @Command("admmascot") 19 | @CommandPermission("omc.admins.commands.adminmascot") 20 | public class AdminMascotsCommands { 21 | 22 | @Subcommand("remove") 23 | @CommandPermission("omc.admins.commands.adminmascot.remove") 24 | public void forceRemoveMascots(Player sender, @Named("player") Player target) throws SQLException { 25 | City city = CityManager.getPlayerCity(target.getUniqueId()); 26 | 27 | if (city == null) { 28 | MessagesManager.sendMessage(sender, Component.text("§cVille inexistante"), Prefix.CITY, MessageType.ERROR, false); 29 | return; 30 | } 31 | 32 | MascotsManager.removeMascotsFromCity(city); 33 | MessagesManager.sendMessage(sender, Component.text("§cVille inexistante"), Prefix.CITY, MessageType.ERROR, false); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/city/sub/mascots/listeners/MascotsTargetListener.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.city.sub.mascots.listeners; 2 | 3 | import fr.openmc.core.features.city.sub.mascots.utils.MascotUtils; 4 | import org.bukkit.entity.Entity; 5 | import org.bukkit.entity.LivingEntity; 6 | import org.bukkit.event.EventHandler; 7 | import org.bukkit.event.Listener; 8 | import org.bukkit.event.entity.EntityTargetLivingEntityEvent; 9 | 10 | public class MascotsTargetListener implements Listener { 11 | 12 | @EventHandler 13 | public void onMobTargetMascot(EntityTargetLivingEntityEvent event) { 14 | LivingEntity target = event.getTarget(); 15 | 16 | if (target == null) return; 17 | if (!MascotUtils.isMascot(target)) return; 18 | 19 | event.setCancelled(true); 20 | } 21 | 22 | @EventHandler 23 | public void onMascotTarget(EntityTargetLivingEntityEvent event) { 24 | Entity entity = event.getEntity(); 25 | 26 | if (MascotUtils.isMascot(entity)) { 27 | event.setCancelled(true); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/city/sub/mayor/ElectionType.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.city.sub.mayor; 2 | 3 | public enum ElectionType { 4 | ELECTION, 5 | OWNER_CHOOSE, 6 | } 7 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/city/sub/mayor/listeners/PhaseListener.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.city.sub.mayor.listeners; 2 | 3 | import fr.openmc.core.OMCPlugin; 4 | import fr.openmc.core.features.city.sub.mayor.managers.MayorManager; 5 | import fr.openmc.core.utils.DateUtils; 6 | import org.bukkit.scheduler.BukkitRunnable; 7 | 8 | import static fr.openmc.core.features.city.sub.mayor.managers.MayorManager.PHASE_1_DAY; 9 | import static fr.openmc.core.features.city.sub.mayor.managers.MayorManager.PHASE_2_DAY; 10 | 11 | public class PhaseListener { 12 | 13 | /** 14 | * Constructor for the PhaseListener class. 15 | * This class is responsible for managing the phases of the mayor election process. 16 | * 17 | * @param plugin The OMCPlugin instance. 18 | */ 19 | public PhaseListener(OMCPlugin plugin) { 20 | BukkitRunnable eventRunnable = new BukkitRunnable() { 21 | @Override 22 | public void run() { 23 | int phase = MayorManager.phaseMayor; 24 | 25 | // PHASE 1 - Elections - Mardi à Mercredi 26 | if (phase == 2 && PHASE_1_DAY == DateUtils.getCurrentDayOfWeek()) { 27 | MayorManager.initPhase1(); 28 | } 29 | 30 | // PHASE 2 - Maire Elu - Jeudi à Jeudi Prochain 31 | if (phase == 1 && PHASE_2_DAY == DateUtils.getCurrentDayOfWeek()) { 32 | MayorManager.initPhase2(); 33 | } 34 | } 35 | }; 36 | // 1200 s = 1 min 37 | eventRunnable.runTaskTimer(plugin, 0, 1200); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/city/sub/mayor/menu/create/MenuType.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.city.sub.mayor.menu.create; 2 | 3 | public enum MenuType { 4 | OWNER, // donc le propriétaire qui choisis 3 Perk comme les elections sont désactivé 5 | CANDIDATE, // donc un joueur normal si les elections sont activé 6 | OWNER_1 // donc le propriétaire qui choisis 1 perk evenementiels 7 | ; 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/city/sub/mayor/models/MayorConstant.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.city.sub.mayor.models; 2 | 3 | import com.j256.ormlite.field.DatabaseField; 4 | import com.j256.ormlite.table.DatabaseTable; 5 | import lombok.Getter; 6 | 7 | @DatabaseTable(tableName = "mayor_constants") 8 | public class MayorConstant { 9 | @DatabaseField(id = true) 10 | private int id = 1; 11 | @DatabaseField(canBeNull = false) 12 | @Getter 13 | private int phase; 14 | 15 | MayorConstant() { 16 | // required for ORMLite 17 | } 18 | 19 | public MayorConstant(int phase) { 20 | this.phase = phase; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/city/sub/mayor/models/MayorVote.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.city.sub.mayor.models; 2 | 3 | import com.j256.ormlite.field.DatabaseField; 4 | import com.j256.ormlite.table.DatabaseTable; 5 | import fr.openmc.core.features.city.City; 6 | import fr.openmc.core.features.city.CityManager; 7 | import fr.openmc.core.features.city.sub.mayor.managers.MayorManager; 8 | import lombok.Getter; 9 | 10 | import java.util.UUID; 11 | 12 | @DatabaseTable(tableName = "mayor_votes") 13 | public class MayorVote { 14 | @DatabaseField(id = true) 15 | @Getter 16 | private UUID voter; 17 | @DatabaseField(canBeNull = false) 18 | private String city; 19 | @DatabaseField(canBeNull = false) 20 | private UUID candidate; 21 | 22 | MayorVote() { 23 | // required for ORMLite 24 | } 25 | 26 | public MayorVote(String city, UUID voterUUID, MayorCandidate candidate) { 27 | this.city = city; 28 | this.voter = voterUUID; 29 | this.candidate = candidate.getUUID(); 30 | } 31 | 32 | public City getCity() { 33 | return CityManager.getCity(city); 34 | } 35 | 36 | public MayorCandidate getCandidate() { 37 | return MayorManager.getCandidate(voter); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/city/sub/mayor/npcs/MayorNPC.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.city.sub.mayor.npcs; 2 | 3 | import de.oliver.fancynpcs.api.Npc; 4 | import lombok.Getter; 5 | import lombok.Setter; 6 | import org.bukkit.Location; 7 | 8 | public class MayorNPC { 9 | 10 | @Getter 11 | private Npc npc; 12 | @Getter 13 | private String cityUUID; 14 | @Getter 15 | @Setter 16 | private Location location; 17 | 18 | public MayorNPC(Npc npc, String cityUUID, Location location) { 19 | this.npc = npc; 20 | this.cityUUID=cityUUID; 21 | this.location=location; 22 | } 23 | } -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/city/sub/mayor/npcs/OwnerNPC.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.city.sub.mayor.npcs; 2 | 3 | import de.oliver.fancynpcs.api.Npc; 4 | import lombok.Getter; 5 | import lombok.Setter; 6 | import org.bukkit.Location; 7 | 8 | public class OwnerNPC { 9 | 10 | @Getter 11 | private Npc npc; 12 | @Getter 13 | private String cityUUID; 14 | @Getter 15 | @Setter 16 | private Location location; 17 | 18 | public OwnerNPC(Npc npc, String cityUUID, Location location) { 19 | this.npc = npc; 20 | this.cityUUID=cityUUID; 21 | this.location=location; 22 | } 23 | } -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/city/sub/mayor/perks/PerkType.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.city.sub.mayor.perks; 2 | 3 | public enum PerkType { 4 | EVENT, 5 | BASIC 6 | ; 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/city/sub/mayor/perks/basic/SymbiosisPerk.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.city.sub.mayor.perks.basic; 2 | 3 | import fr.openmc.core.features.city.City; 4 | import fr.openmc.core.features.city.CityManager; 5 | import fr.openmc.core.features.city.sub.mayor.managers.PerkManager; 6 | import fr.openmc.core.features.city.sub.mayor.perks.Perks; 7 | import org.bukkit.Bukkit; 8 | import org.bukkit.entity.LivingEntity; 9 | import org.bukkit.entity.Player; 10 | import org.bukkit.event.EventHandler; 11 | import org.bukkit.event.Listener; 12 | import org.bukkit.event.entity.EntityDamageEvent; 13 | 14 | public class SymbiosisPerk implements Listener { 15 | 16 | private static final double RADIUS = 10.0; 17 | 18 | @EventHandler 19 | public void onEntityDamage(EntityDamageEvent event) { 20 | if (!(event.getEntity() instanceof Player player)) return; 21 | 22 | City playerCity = CityManager.getPlayerCity(player.getUniqueId()); 23 | if (playerCity == null) return; 24 | 25 | if (!PerkManager.hasPerk(playerCity.getMayor(), Perks.SYMBIOSIS.getId())) return; 26 | 27 | LivingEntity mascot = (LivingEntity) Bukkit.getEntity(playerCity.getMascot().getMascotUUID()); 28 | 29 | if (mascot == null || !mascot.isValid()) return; 30 | 31 | if (!player.getLocation().getWorld().equals(mascot.getLocation().getWorld())) return; 32 | 33 | if (player.getLocation().distance(mascot.getLocation()) <= RADIUS) { 34 | double originalDamage = event.getDamage(); 35 | double reducedDamage = originalDamage * 0.85; 36 | event.setDamage(reducedDamage); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/city/sub/war/WarPendingDefense.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.city.sub.war; 2 | 3 | import fr.openmc.core.features.city.City; 4 | import lombok.Getter; 5 | import lombok.Setter; 6 | 7 | import java.util.*; 8 | 9 | public class WarPendingDefense { 10 | 11 | @Getter 12 | private final City defender; 13 | @Getter 14 | private final City attacker; 15 | @Getter 16 | private List attackers = new ArrayList<>(); 17 | @Getter 18 | private final Set acceptedDefenders = new HashSet<>(); 19 | @Getter 20 | private final int required; 21 | @Getter 22 | @Setter 23 | private boolean alreadyExecuted = false; 24 | 25 | public WarPendingDefense(City attacker, City defender, List attackers, int required) { 26 | this.defender = defender; 27 | this.attacker = attacker; 28 | this.attackers = attackers; 29 | this.required = required; 30 | } 31 | 32 | /** 33 | * Accepts a defender's participation in the war. 34 | * If the number of accepted defenders reaches the required amount, it returns false. 35 | * 36 | * @param uuid The UUID of the defender. 37 | * @return true if the defender was accepted, false if the required number of defenders has already been reached. 38 | */ 39 | public boolean accept(UUID uuid) { 40 | if (acceptedDefenders.size() >= required) return false; 41 | return acceptedDefenders.add(uuid); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/city/sub/war/commands/AdminWarCommand.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.city.sub.war.commands; 2 | 3 | import fr.openmc.core.features.city.City; 4 | import fr.openmc.core.features.city.CityManager; 5 | import fr.openmc.core.features.city.sub.war.War; 6 | import fr.openmc.core.utils.messages.MessageType; 7 | import fr.openmc.core.utils.messages.MessagesManager; 8 | import fr.openmc.core.utils.messages.Prefix; 9 | import net.kyori.adventure.text.Component; 10 | import org.bukkit.entity.Player; 11 | import revxrsal.commands.annotation.Command; 12 | import revxrsal.commands.annotation.Named; 13 | import revxrsal.commands.annotation.Subcommand; 14 | import revxrsal.commands.bukkit.annotation.CommandPermission; 15 | 16 | @Command("admwar") 17 | @CommandPermission("omc.admins.commands.adminwar") 18 | public class AdminWarCommand { 19 | @Subcommand("startCombat") 20 | @CommandPermission("omc.admins.commands.adminwar.startCombat") 21 | void startCombat(Player player, @Named("uuid") String cityUUID) { 22 | City city = CityManager.getCity(cityUUID); 23 | 24 | if (city == null) { 25 | MessagesManager.sendMessage(player, MessagesManager.Message.CITYNOTFOUND.getMessage(), Prefix.STAFF, MessageType.ERROR, false); 26 | return; 27 | } 28 | 29 | if (!city.isInWar() && city.getWar().getPhase() != War.WarPhase.PREPARATION) { 30 | MessagesManager.sendMessage(player, Component.text("Cette ville n'est pas en preparation de guerre!"), Prefix.STAFF, MessageType.ERROR, false); 31 | return; 32 | } 33 | 34 | city.getWar().startCombat(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/city/sub/war/listeners/WarKillListener.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.city.sub.war.listeners; 2 | 3 | import fr.openmc.core.features.city.City; 4 | import fr.openmc.core.features.city.CityManager; 5 | import fr.openmc.core.features.city.sub.war.War; 6 | import org.bukkit.entity.Player; 7 | import org.bukkit.event.EventHandler; 8 | import org.bukkit.event.Listener; 9 | import org.bukkit.event.entity.PlayerDeathEvent; 10 | 11 | import java.util.UUID; 12 | 13 | public class WarKillListener implements Listener { 14 | 15 | @EventHandler 16 | public void onPlayerDeath(PlayerDeathEvent event) { 17 | Player victim = event.getEntity(); 18 | Player killer = victim.getKiller(); 19 | 20 | if (killer == null) return; 21 | 22 | UUID victimUUID = victim.getUniqueId(); 23 | UUID killerUUID = killer.getUniqueId(); 24 | 25 | City victimCity = CityManager.getPlayerCity(victimUUID); 26 | City killerCity = CityManager.getPlayerCity(killerUUID); 27 | 28 | if (victimCity == null || killerCity == null) return; 29 | 30 | War war = victimCity.getWar(); 31 | if (war == null || war.getPhase() != War.WarPhase.COMBAT) return; 32 | 33 | if (!war.isParticipant(killerUUID)) return; 34 | 35 | if (war.isAttacker(killerUUID)) { 36 | war.incrementAttackerKills(); 37 | } else if (war.isDefender(killerUUID)) { 38 | war.incrementDefenderKills(); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/contest/ContestEndEvent.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.contest; 2 | 3 | import fr.openmc.core.features.contest.models.Contest; 4 | import lombok.Getter; 5 | import org.bukkit.event.Event; 6 | import org.bukkit.event.HandlerList; 7 | import org.jetbrains.annotations.NotNull; 8 | 9 | import java.util.List; 10 | import java.util.UUID; 11 | 12 | @Getter 13 | public class ContestEndEvent extends Event { 14 | 15 | private final Contest contestData; 16 | private static final HandlerList HANDLERS = new HandlerList(); 17 | private final List winners; 18 | private final List losers; 19 | 20 | /** 21 | * @param contestData The contest data 22 | * @param winners The list of winners 23 | * @param losers The list of losers 24 | */ 25 | public ContestEndEvent(Contest contestData, List winners, List losers) { 26 | this.contestData = contestData; 27 | this.winners = winners; 28 | this.losers = losers; 29 | } 30 | 31 | public static HandlerList getHandlerList() { 32 | return HANDLERS; 33 | } 34 | 35 | @Override 36 | public @NotNull HandlerList getHandlers() { 37 | return HANDLERS; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/contest/listeners/ContestIntractEvents.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.contest.listeners; 2 | 3 | import dev.lone.itemsadder.api.Events.FurnitureInteractEvent; 4 | import org.bukkit.Sound; 5 | import org.bukkit.event.EventHandler; 6 | import org.bukkit.event.Listener; 7 | import org.bukkit.Bukkit; 8 | 9 | public class ContestIntractEvents implements Listener { 10 | @EventHandler 11 | private void onFurnitureInteractEvent(FurnitureInteractEvent furniture) { 12 | if (furniture.getNamespacedID().equals("omc_contest:borne")) { 13 | furniture.getPlayer().playSound(furniture.getPlayer().getLocation(), Sound.BLOCK_BARREL_OPEN, 1.0F, 0.7F); 14 | Bukkit.dispatchCommand(furniture.getPlayer(), "openmc:contest"); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/contest/models/ContestPlayer.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.contest.models; 2 | 3 | import com.j256.ormlite.field.DatabaseField; 4 | import com.j256.ormlite.table.DatabaseTable; 5 | 6 | import fr.openmc.core.utils.CacheOfflinePlayer; 7 | import lombok.Getter; 8 | import lombok.Setter; 9 | import net.kyori.adventure.text.format.NamedTextColor; 10 | import java.util.UUID; 11 | 12 | @DatabaseTable(tableName = "contest_players") 13 | public class ContestPlayer { 14 | @Getter 15 | @DatabaseField(id = true, columnName = "uuid") 16 | private UUID UUID; 17 | @Getter 18 | @Setter 19 | @DatabaseField(canBeNull = false) 20 | private int points; 21 | @Getter 22 | @DatabaseField(canBeNull = false) 23 | private int camp; 24 | @DatabaseField(canBeNull = false) 25 | private int color; 26 | 27 | ContestPlayer() { 28 | // required for ORMLite 29 | } 30 | 31 | public ContestPlayer(UUID uuid, int points, int camp, NamedTextColor color) { 32 | this.UUID = uuid; 33 | this.points = points; 34 | this.camp = camp; 35 | this.color = color.value(); 36 | } 37 | 38 | public NamedTextColor getColor() { 39 | return NamedTextColor.namedColor(color); 40 | } 41 | 42 | public String getName() { 43 | return CacheOfflinePlayer.getOfflinePlayer(UUID).getName(); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/corporation/CorpPermission.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.corporation; 2 | 3 | import lombok.Getter; 4 | 5 | @Getter 6 | public enum CorpPermission { 7 | OWNER("Propriétaire"), 8 | //CITYMEMBER("Membre de la ville"), 9 | SUPERIOR("Gérant des permission"), 10 | SETCUT("Définir la part de l'entrprise"), 11 | INVITE("Inviter"), 12 | FIRE("Expulser"), 13 | SUPPLY("Réapprovisionner"), 14 | SELLER("Ajouter/Retirer des items en vente"), 15 | LIQUIDATESHOP("Liquider un shop"), 16 | CREATESHOP("Créer un shop"), 17 | DELETESHOP("Supprimer un shop"), 18 | HIRINGER("Embaucher les postulants"), 19 | WITHDRAW("Retirer x$ de l'entreprise"), 20 | DEPOSIT("Ajouter x$ dans l'entreprise") 21 | ; 22 | 23 | private final String displayName; 24 | 25 | CorpPermission(String displayName) { 26 | this.displayName = displayName; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/corporation/ItemsAdderIntegration.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.corporation; 2 | 3 | import dev.lone.itemsadder.api.CustomFurniture; 4 | import dev.lone.itemsadder.api.CustomStack; 5 | import org.bukkit.block.Block; 6 | 7 | public class ItemsAdderIntegration { 8 | 9 | public static boolean placeShopFurniture(Block block) { 10 | CustomStack customFurniture = CustomFurniture.getInstance("omc_company:caisse"); 11 | if (customFurniture == null || block.getType() != org.bukkit.Material.AIR) 12 | return false; 13 | 14 | CustomFurniture.spawn("omc_company:caisse", block); 15 | return true; 16 | } 17 | 18 | public static boolean removeShopFurniture(Block block) { 19 | CustomStack placed = CustomFurniture.byAlreadySpawned(block); 20 | if (placed == null || !placed.getNamespacedID().equals("omc_company:caisse")) 21 | return false; 22 | 23 | CustomFurniture.remove(CustomFurniture.byAlreadySpawned(block).getEntity(), false); 24 | return true; 25 | } 26 | 27 | public static boolean hasFurniture(Block block) { 28 | CustomStack placed = CustomFurniture.byAlreadySpawned(block); 29 | return placed != null && placed.getNamespacedID().equals("omc_company:caisse"); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/corporation/MethodState.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.corporation; 2 | 3 | import lombok.Getter; 4 | 5 | @Getter 6 | public enum MethodState { 7 | SUCCESS, 8 | WARNING, 9 | ERROR, 10 | FAILURE, 11 | ESCAPE, 12 | SPECIAL 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/corporation/company/CompanyOwner.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.corporation.company; 2 | 3 | import fr.openmc.core.features.city.City; 4 | import lombok.Getter; 5 | 6 | import java.util.UUID; 7 | 8 | @Getter 9 | public class CompanyOwner { 10 | 11 | private final City city; 12 | private final UUID player; 13 | 14 | public CompanyOwner(City city) { 15 | this.city = city; 16 | this.player = null; 17 | } 18 | 19 | public CompanyOwner(UUID owner) { 20 | this.city = null; 21 | this.player = owner; 22 | } 23 | 24 | /** 25 | * know if the owner is a city 26 | * 27 | * @return true if it's a city 28 | */ 29 | public boolean isCity() { 30 | return city != null; 31 | } 32 | 33 | /** 34 | * know if the owner is a player 35 | * 36 | * @return true if it's a player 37 | */ 38 | public boolean isPlayer() { 39 | return player != null; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/corporation/data/MerchantData.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.corporation.data; 2 | 3 | import lombok.Getter; 4 | import org.bukkit.inventory.ItemStack; 5 | 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | 9 | @Getter 10 | public class MerchantData { 11 | 12 | private final List depositedItems = new ArrayList<>(); 13 | private double moneyWon = 0; 14 | 15 | /** 16 | * @return the amount of items the merchant has deposit 17 | */ 18 | public int getAllDepositedItemsAmount() { 19 | int amount = 0; 20 | for (ItemStack item : depositedItems) { 21 | amount += item.getAmount(); 22 | } 23 | return amount; 24 | } 25 | 26 | /** 27 | * add an item to the merchant data 28 | * 29 | * @param item the item to add 30 | */ 31 | public void depositItem(ItemStack item) { 32 | depositedItems.add(item); 33 | } 34 | 35 | /** 36 | * add money to the money won of the merchant 37 | * 38 | * @param money the money to add 39 | */ 40 | public void addMoneyWon(double money) { 41 | moneyWon += money; 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/corporation/data/TransactionData.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.corporation.data; 2 | 3 | import java.util.UUID; 4 | 5 | public record TransactionData(double value, String nature, String place, UUID sender) { 6 | } 7 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/corporation/models/CompanyMerchant.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.corporation.models; 2 | 3 | import java.util.UUID; 4 | 5 | import com.j256.ormlite.field.DatabaseField; 6 | import com.j256.ormlite.table.DatabaseTable; 7 | 8 | import lombok.Getter; 9 | 10 | @DatabaseTable(tableName = "company_merchants") 11 | public class CompanyMerchant { 12 | @DatabaseField(id = true) 13 | @Getter 14 | private UUID player; 15 | @DatabaseField 16 | private UUID company; 17 | @DatabaseField(canBeNull = false, defaultValue = "0", columnName = "money_won") 18 | @Getter 19 | private double moneyWon; 20 | 21 | CompanyMerchant() { 22 | // required for ORMLite 23 | } 24 | 25 | public CompanyMerchant(UUID player, UUID company, double moneyWon) { 26 | this.player = player; 27 | this.company = company; 28 | this.moneyWon = moneyWon; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/corporation/models/CompanyPermission.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.corporation.models; 2 | 3 | import java.util.UUID; 4 | 5 | import com.j256.ormlite.field.DatabaseField; 6 | import com.j256.ormlite.table.DatabaseTable; 7 | 8 | import lombok.Getter; 9 | 10 | @DatabaseTable(tableName = "company_permissions") 11 | public class CompanyPermission { 12 | @DatabaseField(canBeNull = false) 13 | private UUID company; 14 | @DatabaseField(canBeNull = false) 15 | private UUID player; 16 | @Getter 17 | @DatabaseField(canBeNull = false) 18 | private String permission; 19 | 20 | CompanyPermission() { 21 | // required for ORMLite 22 | } 23 | 24 | public CompanyPermission(UUID company, UUID player, String permission) { 25 | this.company = company; 26 | this.player = player; 27 | this.permission = permission; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/corporation/models/DBCompany.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.corporation.models; 2 | 3 | import fr.openmc.core.features.city.City; 4 | import fr.openmc.core.features.corporation.company.Company; 5 | 6 | import java.util.UUID; 7 | 8 | import com.j256.ormlite.field.DatabaseField; 9 | import com.j256.ormlite.table.DatabaseTable; 10 | 11 | @DatabaseTable(tableName = "companies") 12 | public class DBCompany { 13 | @DatabaseField(id = true) 14 | private UUID id; 15 | @DatabaseField(canBeNull = false) 16 | private String name; 17 | @DatabaseField(canBeNull = false) 18 | private UUID owner; 19 | @DatabaseField 20 | private String city; 21 | @DatabaseField(canBeNull = false) 22 | private double cut; 23 | @DatabaseField(canBeNull = false) 24 | private double balance; 25 | 26 | DBCompany() { 27 | // required for ORMLite 28 | } 29 | 30 | public DBCompany(UUID id, String name, UUID owner, City city, double cut, double balance) { 31 | this.id = id; 32 | this.name = name; 33 | this.owner = owner; 34 | this.city = city == null ? null : city.getUUID(); 35 | this.cut = cut; 36 | this.balance = balance; 37 | } 38 | 39 | public Company deserialize() { 40 | return new Company(id, name, owner, city, cut, balance); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/corporation/models/DBShop.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.corporation.models; 2 | 3 | import java.util.UUID; 4 | 5 | import com.j256.ormlite.field.DatabaseField; 6 | import com.j256.ormlite.table.DatabaseTable; 7 | 8 | import lombok.Getter; 9 | 10 | @Getter 11 | @DatabaseTable(tableName = "shops") 12 | public class DBShop { 13 | @DatabaseField(id = true) 14 | private UUID id; 15 | 16 | @DatabaseField 17 | private UUID owner; 18 | @DatabaseField 19 | private UUID city; 20 | @DatabaseField 21 | private UUID company; 22 | 23 | @DatabaseField(canBeNull = false) 24 | private double x; 25 | @DatabaseField(canBeNull = false) 26 | private double y; 27 | @DatabaseField(canBeNull = false) 28 | private double z; 29 | 30 | DBShop() { 31 | // required for ORMLite 32 | } 33 | 34 | public DBShop(UUID id, UUID owner, UUID city, UUID company, double x, double y, double z) { 35 | this.id = id; 36 | this.owner = owner; 37 | this.city = city; 38 | this.company = company; 39 | this.x = x; 40 | this.y = y; 41 | this.z = z; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/corporation/models/DBShopItem.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.corporation.models; 2 | 3 | import java.util.UUID; 4 | 5 | import org.bukkit.inventory.ItemStack; 6 | 7 | import com.j256.ormlite.field.DataType; 8 | import com.j256.ormlite.field.DatabaseField; 9 | import com.j256.ormlite.table.DatabaseTable; 10 | 11 | import fr.openmc.core.features.corporation.shops.ShopItem; 12 | import lombok.Getter; 13 | 14 | @Getter 15 | @DatabaseTable(tableName = "shop_items") 16 | public class DBShopItem { 17 | @DatabaseField(canBeNull = false, dataType = DataType.BYTE_ARRAY) 18 | private byte[] items; 19 | @DatabaseField(canBeNull = false) 20 | private UUID shop; 21 | @DatabaseField(canBeNull = false) 22 | private double price; 23 | @DatabaseField(canBeNull = false) 24 | private int amount; 25 | @DatabaseField(canBeNull = false, columnName = "item_uuid") 26 | private UUID itemUuid; 27 | 28 | DBShopItem() { 29 | // required for ORMLite 30 | } 31 | 32 | public DBShopItem(byte[] items, UUID shop, double price, int amount, UUID itemUuid) { 33 | this.items = items; 34 | this.shop = shop; 35 | this.price = price; 36 | this.amount = amount; 37 | this.itemUuid = itemUuid; 38 | } 39 | 40 | public ShopItem deserialize() { 41 | ItemStack item = ItemStack.deserializeBytes(items); 42 | ShopItem shopItem = new ShopItem(item, price, itemUuid); 43 | shopItem.setAmount(amount); 44 | return shopItem; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/corporation/models/DBShopSale.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.corporation.models; 2 | 3 | import java.util.UUID; 4 | 5 | import org.bukkit.inventory.ItemStack; 6 | 7 | import com.j256.ormlite.field.DataType; 8 | import com.j256.ormlite.field.DatabaseField; 9 | import com.j256.ormlite.table.DatabaseTable; 10 | 11 | import fr.openmc.core.features.corporation.shops.ShopItem; 12 | import lombok.Getter; 13 | 14 | @Getter 15 | @DatabaseTable(tableName = "shop_sales") 16 | public class DBShopSale { 17 | @DatabaseField(canBeNull = false, dataType = DataType.BYTE_ARRAY) 18 | private byte[] items; 19 | @DatabaseField(canBeNull = false) 20 | private UUID shop; 21 | @DatabaseField(canBeNull = false, columnName = "sale_uuid") 22 | private UUID saleUuid; 23 | @DatabaseField(canBeNull = false) 24 | private double price; 25 | @DatabaseField(canBeNull = false) 26 | private int amount; 27 | 28 | DBShopSale() { 29 | // required for ORMLite 30 | } 31 | 32 | public DBShopSale(byte[] items, UUID shop, double price, int amount, UUID saleUuid) { 33 | this.items = items; 34 | this.shop = shop; 35 | this.price = price; 36 | this.amount = amount; 37 | this.saleUuid = saleUuid; 38 | } 39 | 40 | public ShopItem deserialize() { 41 | ItemStack item = ItemStack.deserializeBytes(items); 42 | ShopItem shopItem = new ShopItem(item, price, saleUuid); 43 | shopItem.setAmount(amount); 44 | return shopItem; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/corporation/models/Merchant.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.corporation.models; 2 | 3 | import java.util.UUID; 4 | 5 | import com.j256.ormlite.field.DataType; 6 | import com.j256.ormlite.field.DatabaseField; 7 | import com.j256.ormlite.table.DatabaseTable; 8 | 9 | import lombok.Getter; 10 | 11 | @DatabaseTable(tableName = "merchants") 12 | public class Merchant { 13 | @DatabaseField(id = true) 14 | private UUID id; 15 | @Getter 16 | @DatabaseField(dataType = DataType.BYTE_ARRAY) 17 | private byte[] content; 18 | 19 | Merchant() { 20 | // required for ORMLite 21 | } 22 | 23 | public Merchant(UUID id, byte[] content) { 24 | this.id = id; 25 | this.content = content; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/corporation/models/ShopSupplier.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.corporation.models; 2 | 3 | import java.util.UUID; 4 | 5 | import com.j256.ormlite.field.DatabaseField; 6 | import com.j256.ormlite.table.DatabaseTable; 7 | 8 | import lombok.Getter; 9 | 10 | @DatabaseTable(tableName = "shop_suppliers") 11 | @Getter 12 | public class ShopSupplier { 13 | @DatabaseField(id = true) 14 | private UUID id; // différencie les supplier (un joueur peut avoir plusieurs supplier) 15 | @DatabaseField(canBeNull = false) 16 | private UUID shop; 17 | @DatabaseField(canBeNull = false) 18 | private UUID item; 19 | @DatabaseField(canBeNull = false) 20 | private UUID player; 21 | @DatabaseField(defaultValue = "0") 22 | private int amount; 23 | @DatabaseField(defaultValue = "0") 24 | private long time; 25 | 26 | ShopSupplier() { 27 | // required for ORMLite 28 | } 29 | 30 | public ShopSupplier(UUID id, UUID shop, UUID item, UUID player, int amount, long time) { 31 | this.id = id; 32 | this.shop = shop; 33 | this.item = item; 34 | this.player = player; 35 | this.amount = amount; 36 | this.time = time; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/corporation/shops/ShopOwner.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.corporation.shops; 2 | 3 | import fr.openmc.core.features.corporation.company.Company; 4 | import lombok.Getter; 5 | 6 | import java.util.UUID; 7 | 8 | @Getter 9 | public class ShopOwner { 10 | 11 | private final Company company; 12 | private final UUID player; 13 | 14 | /** 15 | * ShopOwner for a company or a player 16 | * @param company to set a company as the owner 17 | */ 18 | 19 | public ShopOwner(Company company) { 20 | this.company = company; 21 | this.player = null; 22 | } 23 | 24 | /** 25 | * ShopOwner for a company or a player 26 | * @param owner to set a player as the owner 27 | */ 28 | public ShopOwner(UUID owner) { 29 | this.company = null; 30 | this.player = owner; 31 | } 32 | 33 | /** 34 | * know if it's a company 35 | */ 36 | public boolean isCompany() { 37 | return company != null; 38 | } 39 | 40 | /** 41 | * know if it's a player 42 | */ 43 | public boolean isPlayer() { 44 | return player != null; 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/corporation/shops/Supply.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.corporation.shops; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | 6 | import java.util.UUID; 7 | 8 | @Getter 9 | public class Supply { 10 | 11 | private final UUID supplier; 12 | private final UUID itemId; 13 | private final UUID supplierUUID; 14 | @Setter 15 | private int amount; 16 | 17 | public Supply(UUID supplier, UUID itemId, int amount) { 18 | this.supplier = supplier; 19 | this.itemId = itemId; 20 | this.amount = amount; 21 | this.supplierUUID = UUID.randomUUID(); 22 | } 23 | 24 | public Supply(UUID supplier, UUID itemId, int amount, UUID supplierUUID) { 25 | this.supplier = supplier; 26 | this.itemId = itemId; 27 | this.amount = amount; 28 | this.supplierUUID = supplierUUID; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/displays/bossbar/BossbarsType.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.displays.bossbar; 2 | 3 | public enum BossbarsType { 4 | HELP, 5 | TUTORIAL 6 | } 7 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/displays/bossbar/listeners/BossbarListener.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.displays.bossbar.listeners; 2 | 3 | import fr.openmc.core.features.displays.bossbar.BossbarManager; 4 | import fr.openmc.core.features.displays.bossbar.BossbarsType; 5 | import org.bukkit.event.EventHandler; 6 | import org.bukkit.event.Listener; 7 | import org.bukkit.event.player.PlayerJoinEvent; 8 | import org.bukkit.event.player.PlayerQuitEvent; 9 | 10 | import static fr.openmc.core.features.displays.bossbar.BossbarManager.bossBarHelp; 11 | 12 | public class BossbarListener implements Listener { 13 | 14 | @EventHandler 15 | public void onPlayerJoin(PlayerJoinEvent event) { 16 | BossbarManager.addBossBar(BossbarsType.HELP, bossBarHelp, event.getPlayer()); 17 | } 18 | 19 | @EventHandler 20 | public void onPlayerQuit(PlayerQuitEvent event) { 21 | BossbarManager.removeBossBar(BossbarsType.HELP, event.getPlayer()); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/displays/holograms/Hologram.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.displays.holograms; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | import org.bukkit.Bukkit; 6 | import org.bukkit.Location; 7 | 8 | @Getter 9 | public class Hologram { 10 | private final String name; 11 | private Location location = new Location(Bukkit.getWorld("world"), 0, 0, 0); // valeur par défaut 12 | @Setter 13 | private float scale = 1.0f; 14 | private String[] lines = new String[0]; 15 | 16 | public Hologram(String name) { 17 | this.name = name; 18 | } 19 | 20 | public void setLocation(double x, double y, double z) { 21 | this.location = new Location(Bukkit.getWorld("world"), x, y, z); 22 | } 23 | 24 | public void setLines(String... lines) { 25 | this.lines = lines; 26 | } 27 | } -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/displays/holograms/HologramInfo.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.displays.holograms; 2 | 3 | import fr.openmc.core.utils.entities.TextDisplay; 4 | 5 | import java.io.File; 6 | 7 | public record HologramInfo(File file, TextDisplay display) { 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/displays/scoreboards/ScoreboardListener.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.displays.scoreboards; 2 | 3 | import org.bukkit.entity.Player; 4 | import org.bukkit.event.EventHandler; 5 | import org.bukkit.event.Listener; 6 | import org.bukkit.event.player.PlayerJoinEvent; 7 | import org.bukkit.event.player.PlayerQuitEvent; 8 | import org.bukkit.scoreboard.Scoreboard; 9 | 10 | import static fr.openmc.core.features.displays.scoreboards.ScoreboardManager.*; 11 | 12 | public class ScoreboardListener implements Listener { 13 | @EventHandler 14 | public void onPlayerJoin(PlayerJoinEvent event) { 15 | Player player = event.getPlayer(); 16 | if (disabledPlayers.contains(player.getUniqueId())) return; 17 | 18 | Scoreboard sb = createNewScoreboard(player); 19 | player.setScoreboard(sb); 20 | } 21 | 22 | @EventHandler 23 | public void onPlayerQuit(PlayerQuitEvent event) { 24 | Player player = event.getPlayer(); 25 | playerScoreboards.remove(player.getUniqueId()); 26 | } 27 | } -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/economy/commands/Baltop.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.economy.commands; 2 | 3 | import org.bukkit.entity.Player; 4 | import revxrsal.commands.annotation.Command; 5 | import revxrsal.commands.annotation.Description; 6 | import revxrsal.commands.bukkit.annotation.CommandPermission; 7 | 8 | import static fr.openmc.core.features.leaderboards.LeaderboardManager.createMoneyTextLeaderboard; 9 | 10 | public class Baltop { 11 | 12 | @Command("baltop") 13 | @Description("Permet de voir le top des joueurs les plus riches") 14 | @CommandPermission("omc.commands.baltop") 15 | public void baltop(Player player) { 16 | player.sendMessage(createMoneyTextLeaderboard()); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/economy/commands/History.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.economy.commands; 2 | 3 | import fr.openmc.core.features.economy.TransactionsMenu; 4 | import org.bukkit.entity.Player; 5 | import revxrsal.commands.annotation.Command; 6 | import revxrsal.commands.annotation.Cooldown; 7 | import revxrsal.commands.annotation.Description; 8 | import revxrsal.commands.annotation.Optional; 9 | import revxrsal.commands.bukkit.annotation.CommandPermission; 10 | 11 | public class History { 12 | @Command("money history") 13 | @Description("Affiche votre historique de transactions") 14 | @CommandPermission("omc.commands.money.history") 15 | @Cooldown(30) 16 | public void history(Player sender, @Optional Player target){ 17 | if (!(sender instanceof Player player)) { return; } 18 | 19 | if (target == null) { 20 | target = player; 21 | } else { 22 | if (!sender.hasPermission("omc.admin.money.history")) { 23 | target = player; 24 | } 25 | } 26 | 27 | new TransactionsMenu(player, target.getUniqueId()).open(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/economy/events/BankDepositEvent.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.economy.events; 2 | 3 | import lombok.Getter; 4 | import org.bukkit.event.Event; 5 | import org.bukkit.event.HandlerList; 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | import java.util.UUID; 9 | 10 | @Getter 11 | public class BankDepositEvent extends Event { 12 | 13 | private final UUID UUID; 14 | private static final HandlerList HANDLERS = new HandlerList(); 15 | 16 | public BankDepositEvent(UUID uuid) { 17 | this.UUID = uuid; 18 | } 19 | 20 | public static HandlerList getHandlerList() { 21 | return HANDLERS; 22 | } 23 | 24 | @Override 25 | public @NotNull HandlerList getHandlers() { 26 | return HANDLERS; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/economy/models/Bank.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.economy.models; 2 | 3 | import java.util.UUID; 4 | 5 | import com.j256.ormlite.field.DatabaseField; 6 | import com.j256.ormlite.table.DatabaseTable; 7 | 8 | import lombok.Getter; 9 | 10 | @Getter 11 | @DatabaseTable(tableName = "banks") 12 | public class Bank { 13 | 14 | @DatabaseField(id = true) 15 | private UUID player; 16 | 17 | @DatabaseField(canBeNull = false, defaultValue = "0") 18 | private double balance; 19 | 20 | Bank() { 21 | // necessary for OrmLite 22 | } 23 | 24 | public Bank(UUID player) { 25 | this.player = player; 26 | this.balance = 0; 27 | } 28 | 29 | public void deposit(double amount) { 30 | balance += amount; 31 | assert balance >= 0; 32 | } 33 | 34 | public void withdraw(double amount) { 35 | balance -= amount; 36 | assert balance >= 0; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/economy/models/EconomyPlayer.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.economy.models; 2 | 3 | import java.util.UUID; 4 | 5 | import com.j256.ormlite.field.DatabaseField; 6 | import com.j256.ormlite.table.DatabaseTable; 7 | 8 | import lombok.Getter; 9 | 10 | @Getter 11 | @DatabaseTable(tableName = "balances") 12 | public class EconomyPlayer { 13 | @DatabaseField(id = true) 14 | private UUID player; 15 | @DatabaseField(canBeNull = false, defaultValue = "0") 16 | private double balance; 17 | 18 | EconomyPlayer() { 19 | // necessary for OrmLite 20 | } 21 | 22 | public EconomyPlayer(UUID player) { 23 | this.player = player; 24 | this.balance = 0; 25 | } 26 | 27 | public void deposit(double amount) { 28 | balance += amount; 29 | } 30 | 31 | public boolean withdraw(double amount) { 32 | if (amount <= balance) { 33 | balance -= amount; 34 | return true; 35 | } 36 | return false; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/friend/Friend.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.friend; 2 | 3 | import java.sql.Timestamp; 4 | import java.util.UUID; 5 | 6 | import com.j256.ormlite.field.DatabaseField; 7 | import com.j256.ormlite.table.DatabaseTable; 8 | 9 | import lombok.Getter; 10 | import lombok.Setter; 11 | 12 | @DatabaseTable(tableName = "friends") 13 | public class Friend { 14 | @DatabaseField(generatedId = true) 15 | private Long id; 16 | @DatabaseField(canBeNull = false) 17 | private UUID first; 18 | @DatabaseField(canBeNull = false) 19 | private UUID second; 20 | @Getter 21 | @DatabaseField(canBeNull = false) 22 | private Timestamp date; 23 | @Setter 24 | @DatabaseField(columnName = "best_friend") 25 | private boolean bestFriend; 26 | 27 | Friend() { 28 | // required for ORMLite 29 | } 30 | 31 | Friend(UUID first, UUID second, Timestamp time) { 32 | this.first = first; 33 | this.second = second; 34 | this.date = time; 35 | } 36 | 37 | public boolean isBestFriend() { 38 | return bestFriend; 39 | } 40 | 41 | public UUID getOther(UUID player) { 42 | return player.equals(first) ? second : first; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/homes/HomeLimits.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.homes; 2 | 3 | import lombok.Getter; 4 | 5 | public enum HomeLimits { 6 | 7 | LIMIT_0(1, 0, 0), 8 | LIMIT_1(3, 5000, 10), 9 | LIMIT_2(5, 10000, 20), 10 | LIMIT_3(7, 15000, 30), 11 | LIMIT_4(10, 20000, 40), 12 | LIMIT_5(13, 25000, 50), 13 | LIMIT_6(15, 30000, 60), 14 | LIMIT_7(17, 35000, 70), 15 | LIMIT_8(20, 40000, 80), 16 | LIMIT_9(23, 45000, 90), 17 | LIMIT_10(25, 50000, 100), 18 | LIMIT_11(27, 55000, 110), 19 | LIMIT_12(30, 60000, 120), 20 | ; 21 | 22 | @Getter 23 | int limit; 24 | @Getter 25 | int price; 26 | @Getter 27 | int ayweniteCost; 28 | 29 | HomeLimits(int limit, int price, int ayweniteCost) { 30 | this.limit = limit; 31 | this.price = price; 32 | this.ayweniteCost = ayweniteCost; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/homes/command/UpgradeHome.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.homes.command; 2 | 3 | import fr.openmc.core.features.homes.menu.HomeUpgradeMenu; 4 | import org.bukkit.entity.Player; 5 | import revxrsal.commands.annotation.Command; 6 | import revxrsal.commands.annotation.Description; 7 | import revxrsal.commands.bukkit.annotation.CommandPermission; 8 | 9 | public class UpgradeHome { 10 | @Command({"upgradehome", "uphome"}) 11 | @Description("Améliore le nombre de homes que tu peux avoir") 12 | @CommandPermission("omc.commands.home.upgradehome") 13 | public void upgradeHome(Player player) { 14 | new HomeUpgradeMenu(player).open(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/homes/events/HomeCreateEvent.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.homes.events; 2 | 3 | import fr.openmc.core.features.homes.models.Home; 4 | import lombok.Getter; 5 | import org.bukkit.entity.Player; 6 | import org.bukkit.event.Event; 7 | import org.bukkit.event.HandlerList; 8 | import org.jetbrains.annotations.NotNull; 9 | 10 | @Getter 11 | public class HomeCreateEvent extends Event { 12 | 13 | private final Home home; 14 | private final Player owner; 15 | 16 | private static final HandlerList HANDLERS = new HandlerList(); 17 | 18 | public HomeCreateEvent(Home home, Player owner) { 19 | this.home = home; 20 | this.owner = owner; 21 | } 22 | 23 | public static HandlerList getHandlerList() { 24 | return HANDLERS; 25 | } 26 | 27 | @Override 28 | public @NotNull HandlerList getHandlers() { 29 | return HANDLERS; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/homes/events/HomeUpgradeEvent.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.homes.events; 2 | 3 | import lombok.Getter; 4 | import org.bukkit.entity.Player; 5 | import org.bukkit.event.Event; 6 | import org.bukkit.event.HandlerList; 7 | import org.jetbrains.annotations.NotNull; 8 | 9 | @Getter 10 | public class HomeUpgradeEvent extends Event { 11 | private final Player owner; 12 | 13 | private static final HandlerList HANDLERS = new HandlerList(); 14 | 15 | public HomeUpgradeEvent(Player owner) { 16 | this.owner = owner; 17 | } 18 | 19 | public static HandlerList getHandlerList() { 20 | return HANDLERS; 21 | } 22 | 23 | @Override 24 | public @NotNull HandlerList getHandlers() { 25 | return HANDLERS; 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/homes/icons/IconCategory.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.homes.icons; 2 | 3 | public enum IconCategory { 4 | ALL, 5 | CUSTOM, 6 | VANILLA 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/homes/icons/IconType.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.homes.icons; 2 | 3 | public enum IconType { 4 | CUSTOM, 5 | VANILLA, 6 | } 7 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/homes/models/HomeLimit.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.homes.models; 2 | 3 | import java.util.UUID; 4 | 5 | import com.j256.ormlite.field.DatabaseField; 6 | import com.j256.ormlite.table.DatabaseTable; 7 | 8 | import fr.openmc.core.features.homes.HomeLimits; 9 | import lombok.Getter; 10 | import lombok.Setter; 11 | 12 | @DatabaseTable(tableName = "home_limits") 13 | public class HomeLimit { 14 | 15 | @Getter 16 | @DatabaseField(id = true) 17 | private UUID player; 18 | @Getter 19 | @Setter 20 | @DatabaseField(canBeNull = false) 21 | private int limit; 22 | 23 | HomeLimit() { 24 | // required for ORMLite 25 | } 26 | 27 | public HomeLimit(UUID player, int limit) { 28 | this.player = player; 29 | this.limit = limit; 30 | } 31 | 32 | public HomeLimit(UUID player, HomeLimits limit) { 33 | this.player = player; 34 | this.limit = limit.getLimit(); 35 | } 36 | 37 | public HomeLimits getHomeLimit() { 38 | for (HomeLimits value : HomeLimits.values()) { 39 | if (value.getLimit() == this.limit) { 40 | return value; 41 | } 42 | } 43 | return null; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/homes/world/WorldDisableInfo.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.homes.world; 2 | 3 | public record WorldDisableInfo(String addedBy, long addedOn) {} 4 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/mailboxes/events/ClaimLetterEvent.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.mailboxes.events; 2 | 3 | import lombok.Getter; 4 | import org.bukkit.entity.Player; 5 | import org.bukkit.event.Event; 6 | import org.bukkit.event.HandlerList; 7 | import org.jetbrains.annotations.NotNull; 8 | 9 | @Getter 10 | public class ClaimLetterEvent extends Event { 11 | 12 | private final Player player; 13 | private static final HandlerList HANDLERS = new HandlerList(); 14 | 15 | public ClaimLetterEvent(Player player) { 16 | this.player = player; 17 | } 18 | 19 | public static HandlerList getHandlerList() { 20 | return HANDLERS; 21 | } 22 | 23 | @Override 24 | public @NotNull HandlerList getHandlers() { 25 | return HANDLERS; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/mailboxes/menu/PlayersList.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.mailboxes.menu; 2 | 3 | 4 | import fr.openmc.core.features.mailboxes.MailboxManager; 5 | import fr.openmc.core.features.mailboxes.utils.PaginatedMailbox; 6 | import fr.openmc.core.utils.ItemUtils; 7 | import org.bukkit.Bukkit; 8 | import org.bukkit.entity.Player; 9 | import org.bukkit.inventory.ItemStack; 10 | 11 | public class PlayersList extends PaginatedMailbox { 12 | public PlayersList(Player player) { 13 | super(player); 14 | for (Player onlinePlayer : Bukkit.getOnlinePlayers()) { 15 | if (onlinePlayer == player) continue; 16 | if (!MailboxManager.canSend(player, onlinePlayer)) continue; 17 | pageItems.add(ItemUtils.getPlayerHead(onlinePlayer.getUniqueId())); 18 | } 19 | initInventory(); 20 | } 21 | 22 | @Override 23 | public void openInventory() { 24 | player.openInventory(this.inventory); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/mailboxes/utils/MailboxInv.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.mailboxes.utils; 2 | 3 | import fr.openmc.core.OMCPlugin; 4 | import org.bukkit.entity.Player; 5 | import org.bukkit.inventory.Inventory; 6 | import org.bukkit.inventory.InventoryHolder; 7 | import org.jetbrains.annotations.NotNull; 8 | 9 | import static fr.openmc.core.features.mailboxes.utils.MailboxMenuManager.playerInventories; 10 | import static fr.openmc.core.features.mailboxes.utils.MailboxUtils.sendFailureMessage; 11 | 12 | public abstract class MailboxInv implements InventoryHolder { 13 | protected static String invErrorMessage; 14 | protected final Player player; 15 | protected final OMCPlugin plugin = OMCPlugin.getInstance(); 16 | protected Inventory inventory; 17 | 18 | public MailboxInv(Player player) { 19 | this.player = player; 20 | } 21 | 22 | public void addInventory() { 23 | playerInventories.put(player, this); 24 | } 25 | 26 | public void removeInventory() { 27 | playerInventories.remove(player); 28 | } 29 | 30 | @Override 31 | public @NotNull Inventory getInventory() { 32 | return this.inventory; 33 | } 34 | 35 | public void openInventory() { 36 | if (inventory == null) { 37 | sendInvErrorMessage(player); 38 | return; 39 | } 40 | player.openInventory(this.inventory); 41 | } 42 | 43 | protected void sendInvErrorMessage(Player player) { 44 | if (invErrorMessage == null) return; 45 | sendFailureMessage(player, invErrorMessage); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/mainmenu/MainMenu.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.mainmenu; 2 | 3 | import fr.openmc.api.packetmenulib.PacketMenuLib; 4 | import fr.openmc.core.OMCPlugin; 5 | import fr.openmc.core.features.mainmenu.listeners.PacketListener; 6 | import fr.openmc.core.features.mainmenu.menus.Page1; 7 | import org.bukkit.entity.Player; 8 | 9 | public class MainMenu { 10 | 11 | private final OMCPlugin plugin; 12 | 13 | public MainMenu(OMCPlugin plugin) { 14 | this.plugin = plugin; 15 | new PacketListener(plugin); 16 | } 17 | 18 | public static void openMainMenu(Player player) { 19 | PacketMenuLib.openMenu(new Page1(player), player); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/mainmenu/commands/MainMenuCommand.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.mainmenu.commands; 2 | 3 | import fr.openmc.core.features.mainmenu.MainMenu; 4 | import org.bukkit.entity.Player; 5 | import revxrsal.commands.annotation.Command; 6 | import revxrsal.commands.annotation.Description; 7 | import revxrsal.commands.bukkit.annotation.CommandPermission; 8 | 9 | public class MainMenuCommand { 10 | @Command("menu") 11 | @Description("Permet d'ouvrir le menu principal d'OpenMC") 12 | @CommandPermission("omc.commands.menu") 13 | public void menuCommand(Player player) { 14 | MainMenu.openMainMenu(player); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/milestones/MilestoneCommand.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.milestones; 2 | 3 | import fr.openmc.core.features.milestones.menus.MainMilestonesMenu; 4 | import org.bukkit.entity.Player; 5 | import revxrsal.commands.annotation.Command; 6 | import revxrsal.commands.annotation.DefaultFor; 7 | import revxrsal.commands.bukkit.annotation.CommandPermission; 8 | 9 | @Command("milestones") 10 | @CommandPermission("omc.commands.milestones") 11 | public class MilestoneCommand { 12 | @DefaultFor("~") 13 | void mainCommand(Player player) { 14 | new MainMilestonesMenu(player).open(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/milestones/MilestoneModel.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.milestones; 2 | 3 | import com.j256.ormlite.field.DatabaseField; 4 | import com.j256.ormlite.table.DatabaseTable; 5 | import lombok.Getter; 6 | import lombok.Setter; 7 | 8 | @DatabaseTable(tableName = "milestone") 9 | @Getter 10 | public class MilestoneModel { 11 | @DatabaseField(id = true, columnName = "uuid") 12 | private java.util.UUID UUID; 13 | @DatabaseField 14 | private String type; 15 | @DatabaseField(canBeNull = false) 16 | @Setter 17 | private int step; 18 | 19 | MilestoneModel() { 20 | // required for ORMLite 21 | } 22 | 23 | public MilestoneModel(java.util.UUID uuid, MilestoneType type, int step) { 24 | this.UUID = uuid; 25 | this.type = type.name(); 26 | this.step = step; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/milestones/MilestoneType.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.milestones; 2 | 3 | import fr.openmc.core.features.milestones.tutorial.TutorialMilestone; 4 | import lombok.Getter; 5 | 6 | @Getter 7 | public enum MilestoneType { 8 | TUTORIAL( 9 | new TutorialMilestone() 10 | ); 11 | 12 | private final Milestone milestone; 13 | 14 | MilestoneType(Milestone milestone) { 15 | this.milestone = milestone; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/milestones/listeners/PlayerJoin.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.milestones.listeners; 2 | 3 | import fr.openmc.core.features.milestones.Milestone; 4 | import fr.openmc.core.features.milestones.MilestoneModel; 5 | import fr.openmc.core.features.milestones.MilestonesManager; 6 | import org.bukkit.entity.Player; 7 | import org.bukkit.event.EventHandler; 8 | import org.bukkit.event.Listener; 9 | import org.bukkit.event.player.PlayerJoinEvent; 10 | 11 | public class PlayerJoin implements Listener { 12 | 13 | @EventHandler 14 | void onJoin(PlayerJoinEvent event) { 15 | Player player = event.getPlayer(); 16 | 17 | for (Milestone milestone : MilestonesManager.getRegisteredMilestones()) { 18 | if (!milestone.getPlayerData().containsKey(player.getUniqueId())) { 19 | milestone.getPlayerData().put(player.getUniqueId(), new MilestoneModel( 20 | player.getUniqueId(), 21 | milestone.getType(), 22 | 0 23 | )); 24 | } 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/milestones/tutorial/TutorialHologram.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.milestones.tutorial; 2 | 3 | import dev.lone.itemsadder.api.FontImages.FontImageWrapper; 4 | import fr.openmc.core.features.displays.holograms.Hologram; 5 | 6 | public class TutorialHologram extends Hologram { 7 | 8 | public TutorialHologram() { 9 | super("tutorial"); 10 | 11 | this.setLines( 12 | "§f" + new FontImageWrapper("omc_icons:openmc").getString(), 13 | "§fBienvenue sur §dOpenMC V2§f!", 14 | "§fCette version est basée sur les §2Villes", 15 | "§f", 16 | "§fPour acceder au tutoriel, utilisez la commande §a/milestones§f.", 17 | "§fC'est votre §dserveur §f!", 18 | "§8§m §r", 19 | "§fLiens utiles : §5/socials" 20 | 21 | ); 22 | this.setScale(0.5f); 23 | this.setLocation(0, 2, 0); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/milestones/tutorial/TutorialStep.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.milestones.tutorial; 2 | 3 | import fr.openmc.core.features.milestones.tutorial.quests.*; 4 | import fr.openmc.core.features.quests.objects.Quest; 5 | import lombok.Getter; 6 | 7 | @Getter 8 | public enum TutorialStep { 9 | BREAK_AYWENITE(null), 10 | CITY_CREATE(null), 11 | HOME_CREATE(null), 12 | HOME_UPGRADE(null), 13 | OPEN_QUEST(null), 14 | FINISH_QUEST(null), 15 | OPEN_ADMINSHOP(null), 16 | SELL_BUY_ADMINSHOP(null), 17 | SPARE_BANK(null), 18 | //TODO: ajouter des quêtes autour des shops/entreprises lorsque refonte faite 19 | OPEN_SETTINGS(null), 20 | OPEN_CONTEST(null), 21 | CLAIM_LETTER(null), 22 | ; 23 | 24 | private Quest quest; 25 | 26 | TutorialStep(Quest quest) { 27 | this.quest = quest; 28 | } 29 | 30 | // ça peut paraitre con de faire ça mais obligatoire pour pas avoir d'instance nulle de quete. 31 | static { 32 | BREAK_AYWENITE.quest = new BreakAyweniteQuest(); 33 | CITY_CREATE.quest = new CityCreateQuest(); 34 | HOME_CREATE.quest = new HomeCreateQuest(); 35 | HOME_UPGRADE.quest = new HomeUpgradeQuest(); 36 | OPEN_QUEST.quest = new OpenQuestMenuQuest(); 37 | FINISH_QUEST.quest = new FinishQuestQuest(); 38 | OPEN_ADMINSHOP.quest = new OpenAdminShopMenuQuest(); 39 | SELL_BUY_ADMINSHOP.quest = new SellBuyQuest(); 40 | SPARE_BANK.quest = new SpareBankQuest(); 41 | OPEN_SETTINGS.quest = new OpenSettingsMenuQuest(); 42 | OPEN_CONTEST.quest = new OpenContestMenuQuest(); 43 | CLAIM_LETTER.quest = new ClaimLetterQuest(); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/milestones/tutorial/listeners/TutorialBossBarEvent.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.milestones.tutorial.listeners; 2 | 3 | import fr.openmc.core.features.displays.bossbar.BossbarManager; 4 | import fr.openmc.core.features.displays.bossbar.BossbarsType; 5 | import fr.openmc.core.features.milestones.tutorial.utils.TutorialUtils; 6 | import org.bukkit.entity.Player; 7 | import org.bukkit.event.EventHandler; 8 | import org.bukkit.event.Listener; 9 | import org.bukkit.event.player.PlayerJoinEvent; 10 | import org.bukkit.event.player.PlayerQuitEvent; 11 | 12 | public class TutorialBossBarEvent implements Listener { 13 | 14 | @EventHandler 15 | void onPlayerJoin(PlayerJoinEvent event) { 16 | Player player = event.getPlayer(); 17 | 18 | TutorialUtils.setBossBar(player); 19 | } 20 | 21 | @EventHandler 22 | public void onPlayerQuit(PlayerQuitEvent event) { 23 | BossbarManager.removeBossBar(BossbarsType.TUTORIAL, event.getPlayer()); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/privatemessage/command/PrivateMessageCommand.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.privatemessage.command; 2 | 3 | import fr.openmc.core.features.privatemessage.PrivateMessageManager; 4 | import org.bukkit.entity.Player; 5 | import revxrsal.commands.annotation.Command; 6 | import revxrsal.commands.annotation.Description; 7 | import revxrsal.commands.annotation.Named; 8 | import revxrsal.commands.bukkit.annotation.CommandPermission; 9 | 10 | public class PrivateMessageCommand { 11 | 12 | @Command("msg") 13 | @Description("Envoie un message privé à un joueur") 14 | @CommandPermission("omc.commands.privatemessage.msg") 15 | public void sendPrivateMessage(Player player, @Named("Receiver") Player target, @Named("message") String message) { 16 | PrivateMessageManager.getInstance().sendPrivateMessage(player, target, message); 17 | } 18 | 19 | @Command("r") 20 | @Description("Répond à un message privé du dernier joueur qui vous a envoyé un message") 21 | @CommandPermission("omc.commands.privatemessage.reply") 22 | public void replyToLastMessage(Player player, @Named("message") String message) { 23 | PrivateMessageManager.getInstance().replyToLastMessage(player, message); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/quests/command/QuestCommand.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.quests.command; 2 | 3 | import fr.openmc.core.features.quests.menus.QuestsMenu; 4 | import fr.openmc.core.utils.messages.MessageType; 5 | import fr.openmc.core.utils.messages.MessagesManager; 6 | import fr.openmc.core.utils.messages.Prefix; 7 | import org.bukkit.entity.Player; 8 | import revxrsal.commands.annotation.*; 9 | 10 | @Command({"quest", "quests"}) 11 | @Description("Commande pour les quêtes") 12 | public class QuestCommand { 13 | 14 | @DefaultFor({"~"}) 15 | @Description("Ouvre le menu des quêtes") 16 | public static void onQuest(Player player) { 17 | new QuestsMenu(player).open(); 18 | } 19 | 20 | @Subcommand("open") 21 | @Description("Ouvre le menu des quêtes") 22 | public void resetProgress(Player sender, @Optional Player target) { 23 | if (target == null || target == sender) { 24 | new QuestsMenu(sender).open(); 25 | } else { 26 | if (sender.hasPermission("omc.quests.admin")) new QuestsMenu(target).open(); 27 | else MessagesManager.sendMessage(sender, MessagesManager.Message.NOPERMISSION.getMessage(), Prefix.OPENMC, MessageType.ERROR, true); 28 | 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/quests/events/QuestCompleteEvent.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.quests.events; 2 | 3 | import lombok.Getter; 4 | import org.bukkit.entity.Player; 5 | import org.bukkit.event.Event; 6 | import org.bukkit.event.HandlerList; 7 | import org.jetbrains.annotations.NotNull; 8 | 9 | @Getter 10 | public class QuestCompleteEvent extends Event { 11 | 12 | private final Player player; 13 | 14 | private static final HandlerList HANDLERS = new HandlerList(); 15 | 16 | public QuestCompleteEvent(Player player) { 17 | this.player = player; 18 | } 19 | 20 | public static HandlerList getHandlerList() { 21 | return HANDLERS; 22 | } 23 | 24 | @Override 25 | public @NotNull HandlerList getHandlers() { 26 | return HANDLERS; 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/quests/quests/BreakStoneQuest.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.quests.quests; 2 | 3 | import fr.openmc.core.features.quests.objects.Quest; 4 | import fr.openmc.core.features.quests.objects.QuestTier; 5 | import fr.openmc.core.features.quests.rewards.QuestMoneyReward; 6 | import org.bukkit.Material; 7 | import org.bukkit.block.Block; 8 | import org.bukkit.event.EventHandler; 9 | import org.bukkit.event.EventPriority; 10 | import org.bukkit.event.Listener; 11 | import org.bukkit.event.block.BlockBreakEvent; 12 | import org.bukkit.inventory.ItemStack; 13 | 14 | import java.util.List; 15 | 16 | public class BreakStoneQuest extends Quest implements Listener { 17 | 18 | public BreakStoneQuest() { 19 | super("Casseur de pierres", List.of("Miner {target} blocs de pierre"), new ItemStack(Material.DIAMOND_PICKAXE)); 20 | 21 | 22 | this.addTiers( 23 | new QuestTier(10000, new QuestMoneyReward(2000)), 24 | new QuestTier(30000, new QuestMoneyReward(4000)), 25 | new QuestTier(80000, new QuestMoneyReward(6000)), 26 | new QuestTier(150000, new QuestMoneyReward(10000)) 27 | ); 28 | } 29 | 30 | @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) 31 | public void onPlayerBreak(BlockBreakEvent event) { 32 | ItemStack tool = event.getPlayer().getInventory().getItemInMainHand(); 33 | Block block = event.getBlock(); 34 | if (block.getType().equals(Material.STONE)) { 35 | this.incrementProgress(event.getPlayer().getUniqueId()); 36 | } 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/quests/quests/ChickenThrowerQuest.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.quests.quests; 2 | 3 | import fr.openmc.core.features.quests.objects.Quest; 4 | import fr.openmc.core.features.quests.objects.QuestTier; 5 | import fr.openmc.core.features.quests.rewards.QuestMoneyReward; 6 | import org.bukkit.Material; 7 | import org.bukkit.event.EventHandler; 8 | import org.bukkit.event.EventPriority; 9 | import org.bukkit.event.Listener; 10 | import org.bukkit.event.player.PlayerEggThrowEvent; 11 | import org.bukkit.inventory.ItemStack; 12 | 13 | import java.util.List; 14 | 15 | public class ChickenThrowerQuest extends Quest implements Listener { 16 | 17 | public ChickenThrowerQuest() { 18 | super( 19 | "Lanceur de Poules", 20 | List.of("Lancer {target} oeufs"), 21 | new ItemStack(Material.EGG) 22 | ); 23 | 24 | this.addTiers( 25 | new QuestTier(50, new QuestMoneyReward(500)), 26 | new QuestTier(200, new QuestMoneyReward(2000)), 27 | new QuestTier(500, new QuestMoneyReward(5000)), 28 | new QuestTier(1000, new QuestMoneyReward(10000)) 29 | ); 30 | } 31 | 32 | @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) 33 | public void onEggThrow(PlayerEggThrowEvent event) { 34 | this.incrementProgress(event.getPlayer().getUniqueId(), 1); 35 | } 36 | } -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/quests/quests/ConsumeKebabQuest.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.quests.quests; 2 | 3 | import fr.openmc.core.features.quests.objects.Quest; 4 | import fr.openmc.core.features.quests.objects.QuestTier; 5 | import fr.openmc.core.features.quests.rewards.QuestMoneyReward; 6 | import fr.openmc.core.items.CustomItemRegistry; 7 | import org.bukkit.event.EventHandler; 8 | import org.bukkit.event.EventPriority; 9 | import org.bukkit.event.Listener; 10 | import org.bukkit.event.player.PlayerItemConsumeEvent; 11 | import org.bukkit.inventory.ItemStack; 12 | 13 | import java.util.List; 14 | 15 | public class ConsumeKebabQuest extends Quest implements Listener { 16 | 17 | public ConsumeKebabQuest() { 18 | super("Miam Miam", List.of("Manger {target} kebab{s}"), CustomItemRegistry.getByName("omc_foods:kebab").getBest()); 19 | 20 | this.addTiers( 21 | new QuestTier(10, new QuestMoneyReward(30)), 22 | new QuestTier(64, new QuestMoneyReward(80)), 23 | new QuestTier(256, new QuestMoneyReward(160)), 24 | new QuestTier(1024, new QuestMoneyReward(1000)) 25 | ); 26 | } 27 | 28 | @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) 29 | public void onPlayerConsume(PlayerItemConsumeEvent event) { 30 | ItemStack item = event.getItem(); 31 | if (item.isSimilar(CustomItemRegistry.getByName("omc_foods:kebab").getBest())) { 32 | this.incrementProgress(event.getPlayer().getUniqueId()); 33 | } 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/quests/quests/CraftCakeQuest.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.quests.quests; 2 | 3 | import fr.openmc.core.features.quests.objects.Quest; 4 | import fr.openmc.core.features.quests.objects.QuestTier; 5 | import fr.openmc.core.features.quests.rewards.QuestMoneyReward; 6 | import org.bukkit.Material; 7 | import org.bukkit.event.EventHandler; 8 | import org.bukkit.event.EventPriority; 9 | import org.bukkit.event.Listener; 10 | import org.bukkit.event.inventory.CraftItemEvent; 11 | 12 | import java.util.List; 13 | 14 | public class CraftCakeQuest extends Quest implements Listener { 15 | 16 | public CraftCakeQuest() { 17 | super("Le pâtissier", List.of("Craft {target} gâteaux"), Material.CAKE); 18 | 19 | this.addTiers( 20 | new QuestTier(64, new QuestMoneyReward(100)), 21 | new QuestTier(256, new QuestMoneyReward(400)) 22 | ); 23 | } 24 | 25 | @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) 26 | public void onPlayerCraft(CraftItemEvent event) { 27 | if (event.getRecipe().getResult().getType().equals(Material.CAKE)) { 28 | this.incrementProgress(event.getWhoClicked().getUniqueId()); 29 | } 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/quests/quests/EnchantFirstItemQuest.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.quests.quests; 2 | 3 | import fr.openmc.core.features.quests.objects.Quest; 4 | import fr.openmc.core.features.quests.objects.QuestTier; 5 | import fr.openmc.core.features.quests.rewards.QuestMoneyReward; 6 | import org.bukkit.Material; 7 | import org.bukkit.event.EventHandler; 8 | import org.bukkit.event.EventPriority; 9 | import org.bukkit.event.Listener; 10 | import org.bukkit.event.enchantment.EnchantItemEvent; 11 | import org.bukkit.inventory.ItemStack; 12 | 13 | import java.util.List; 14 | 15 | public class EnchantFirstItemQuest extends Quest implements Listener { 16 | 17 | public EnchantFirstItemQuest() { 18 | super("Abracadabra", List.of("Enchanter un objet pour la première fois"), Material.ENCHANTING_TABLE); 19 | 20 | this.addTiers( 21 | new QuestTier(1, new QuestMoneyReward(200)) 22 | ); 23 | } 24 | 25 | @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) 26 | public void onEnchantItem(EnchantItemEvent event) { 27 | ItemStack item = event.getItem(); 28 | if (item.getType() != Material.AIR) { 29 | this.incrementProgress(event.getEnchanter().getUniqueId()); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/quests/quests/KillPlayersQuest.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.quests.quests; 2 | 3 | import fr.openmc.core.features.quests.objects.Quest; 4 | import fr.openmc.core.features.quests.objects.QuestTier; 5 | import fr.openmc.core.features.quests.rewards.QuestMoneyReward; 6 | import org.bukkit.Material; 7 | import org.bukkit.entity.Player; 8 | import org.bukkit.event.EventHandler; 9 | import org.bukkit.event.EventPriority; 10 | import org.bukkit.event.Listener; 11 | import org.bukkit.event.entity.PlayerDeathEvent; 12 | 13 | import java.util.List; 14 | 15 | public class KillPlayersQuest extends Quest implements Listener { 16 | 17 | public KillPlayersQuest() { 18 | super( 19 | "Tueur à gage", 20 | List.of("Tuer {target} joueurs"), 21 | Material.IRON_SWORD 22 | ); 23 | 24 | this.addTiers( 25 | new QuestTier(5, new QuestMoneyReward(2500)), 26 | new QuestTier(20, new QuestMoneyReward(5000)), 27 | new QuestTier(30, new QuestMoneyReward(10000)) 28 | ); 29 | } 30 | 31 | @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) 32 | public void onPlayerKill(PlayerDeathEvent event) { 33 | if (event.getEntity().getKiller() instanceof Player player) { 34 | this.incrementProgress(player.getUniqueId(), 1); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/quests/quests/KillSuperCreeperQuest.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.quests.quests; 2 | 3 | import fr.openmc.core.features.quests.objects.Quest; 4 | import fr.openmc.core.features.quests.objects.QuestTier; 5 | import fr.openmc.core.features.quests.rewards.QuestMoneyReward; 6 | import org.bukkit.Material; 7 | import org.bukkit.entity.Creeper; 8 | import org.bukkit.entity.Player; 9 | import org.bukkit.event.EventHandler; 10 | import org.bukkit.event.EventPriority; 11 | import org.bukkit.event.Listener; 12 | import org.bukkit.event.entity.EntityDeathEvent; 13 | 14 | import java.util.List; 15 | 16 | public class KillSuperCreeperQuest extends Quest implements Listener { 17 | 18 | public KillSuperCreeperQuest() { 19 | super( 20 | "Le Boss des Creepers", 21 | List.of("Tuer {target} creepers super chargés"), 22 | Material.CREEPER_HEAD 23 | ); 24 | 25 | this.addTier(new QuestTier(1, new QuestMoneyReward(1000))); 26 | } 27 | 28 | @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) 29 | public void onPlayerKill(EntityDeathEvent event) { 30 | Player player = event.getEntity().getKiller(); 31 | if (player != null && event.getEntity() instanceof Creeper creeper && creeper.isPowered()) { 32 | this.incrementProgress(player.getUniqueId()); 33 | } 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/quests/quests/KillZombieQuest.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.quests.quests; 2 | 3 | import fr.openmc.core.features.quests.objects.Quest; 4 | import fr.openmc.core.features.quests.objects.QuestTier; 5 | import fr.openmc.core.features.quests.rewards.QuestMoneyReward; 6 | import org.bukkit.Material; 7 | import org.bukkit.entity.Player; 8 | import org.bukkit.entity.Zombie; 9 | import org.bukkit.event.EventHandler; 10 | import org.bukkit.event.EventPriority; 11 | import org.bukkit.event.Listener; 12 | import org.bukkit.event.entity.EntityDeathEvent; 13 | 14 | import java.util.List; 15 | 16 | public class KillZombieQuest extends Quest implements Listener { 17 | 18 | public KillZombieQuest() { 19 | super("Apocalypse zombie ?", List.of("Tuer {target} zombies"), Material.ZOMBIE_HEAD); 20 | 21 | this.addTiers( 22 | new QuestTier(1000, new QuestMoneyReward(8000)), 23 | new QuestTier(4000, new QuestMoneyReward(10000)), 24 | new QuestTier(10000, new QuestMoneyReward(15000)) 25 | ); 26 | } 27 | 28 | @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) 29 | public void onZombieKill(EntityDeathEvent event) { 30 | if (event.getEntity().getKiller() instanceof Player player && event.getEntity() instanceof Zombie) { 31 | this.incrementProgress(player.getUniqueId()); 32 | } 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/quests/quests/SaveTheEarthQuest.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.quests.quests; 2 | 3 | import fr.openmc.core.features.quests.objects.Quest; 4 | import fr.openmc.core.features.quests.objects.QuestTier; 5 | import fr.openmc.core.features.quests.rewards.QuestItemReward; 6 | import org.bukkit.Material; 7 | import org.bukkit.event.EventHandler; 8 | import org.bukkit.event.EventPriority; 9 | import org.bukkit.event.Listener; 10 | import org.bukkit.event.world.StructureGrowEvent; 11 | 12 | import java.util.List; 13 | 14 | public class SaveTheEarthQuest extends Quest implements Listener { 15 | 16 | public SaveTheEarthQuest() { 17 | super("Sauvons la planète", List.of("Planter {target} arbres et les faire grandir avec des poudres d'os"), Material.OAK_SAPLING); 18 | 19 | this.addTiers( 20 | new QuestTier(10, new QuestItemReward(Material.OAK_LOG, 32)), 21 | new QuestTier(40, new QuestItemReward(Material.OAK_LOG, 64)), 22 | new QuestTier(100, new QuestItemReward(Material.OAK_LOG, 128)), 23 | new QuestTier(1000, new QuestItemReward(Material.OAK_LOG, 256)) 24 | ); 25 | } 26 | 27 | @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) 28 | public void onPlayerBreak(StructureGrowEvent event) { 29 | if (event.getPlayer() != null) 30 | this.incrementProgress(event.getPlayer().getUniqueId()); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/quests/quests/SmeltIronQuest.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.quests.quests; 2 | 3 | import fr.openmc.core.features.quests.objects.Quest; 4 | import fr.openmc.core.features.quests.objects.QuestTier; 5 | import fr.openmc.core.features.quests.rewards.QuestMoneyReward; 6 | import org.bukkit.Material; 7 | import org.bukkit.event.EventHandler; 8 | import org.bukkit.event.EventPriority; 9 | import org.bukkit.event.Listener; 10 | import org.bukkit.event.inventory.FurnaceExtractEvent; 11 | 12 | import java.util.List; 13 | 14 | public class SmeltIronQuest extends Quest implements Listener { 15 | 16 | public SmeltIronQuest() { 17 | super("Chaud devant !", List.of("Faire fondre {target} lingots de fer"), Material.IRON_ORE); 18 | 19 | this.addTiers( 20 | new QuestTier(256, new QuestMoneyReward(2000)), 21 | new QuestTier(512, new QuestMoneyReward(4000)), 22 | new QuestTier(1536, new QuestMoneyReward(8000)) 23 | ); 24 | } 25 | 26 | @EventHandler(priority = EventPriority.MONITOR) 27 | public void onPlayerSmelt(FurnaceExtractEvent event) { 28 | if (event.getItemType().equals(Material.IRON_INGOT)) { 29 | int amount = event.getItemAmount(); 30 | this.incrementProgress(event.getPlayer().getUniqueId(), amount); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/quests/quests/WalkQuests.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.quests.quests; 2 | 3 | import fr.openmc.core.features.quests.objects.Quest; 4 | import fr.openmc.core.features.quests.objects.QuestTier; 5 | import fr.openmc.core.features.quests.rewards.QuestMoneyReward; 6 | import org.bukkit.Material; 7 | import org.bukkit.entity.Player; 8 | import org.bukkit.event.EventHandler; 9 | import org.bukkit.event.EventPriority; 10 | import org.bukkit.event.Listener; 11 | import org.bukkit.event.player.PlayerMoveEvent; 12 | 13 | import java.util.List; 14 | 15 | public class WalkQuests extends Quest implements Listener { 16 | public WalkQuests() { 17 | super("Le randonneur", List.of("Marcher {target} blocs"), Material.LEATHER_BOOTS, true); 18 | 19 | this.addTiers( 20 | new QuestTier(4000, new QuestMoneyReward(500)), 21 | new QuestTier(10000, new QuestMoneyReward(1200)), 22 | new QuestTier(30000, new QuestMoneyReward(3200)), 23 | new QuestTier(100000, new QuestMoneyReward(8000)) 24 | ); 25 | } 26 | 27 | @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) 28 | public void onPlayerMove(PlayerMoveEvent event) { 29 | Player player = event.getPlayer(); 30 | if ( 31 | (event.getFrom().getBlockX() != event.getTo().getBlockX() 32 | || event.getFrom().getBlockZ() != event.getTo().getBlockZ()) 33 | && !player.isFlying() 34 | && !player.isGliding() 35 | && !player.isInsideVehicle() 36 | ) { 37 | this.incrementProgress(player.getUniqueId()); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/quests/quests/WinContestQuest.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.quests.quests; 2 | 3 | import fr.openmc.core.features.contest.ContestEndEvent; 4 | import fr.openmc.core.features.quests.objects.Quest; 5 | import fr.openmc.core.features.quests.objects.QuestTier; 6 | import fr.openmc.core.features.quests.rewards.QuestItemReward; 7 | import fr.openmc.core.items.CustomItemRegistry; 8 | import org.bukkit.Material; 9 | import org.bukkit.event.EventHandler; 10 | import org.bukkit.event.Listener; 11 | 12 | import java.util.List; 13 | import java.util.UUID; 14 | 15 | public class WinContestQuest extends Quest implements Listener { 16 | 17 | public WinContestQuest() { 18 | super( 19 | "Choisir son camp", 20 | List.of("Gagne {target} contest"), 21 | Material.NAUTILUS_SHELL 22 | ); 23 | 24 | this.addTier(new QuestTier(1, new QuestItemReward(CustomItemRegistry.getByName("omc_contest:contest_shell").getBest(), 5))); 25 | } 26 | 27 | @EventHandler 28 | public void onEndContest(ContestEndEvent event) { 29 | for (UUID playerUUID : event.getWinners()) { 30 | this.incrementProgress(playerUUID); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/quests/rewards/QuestMethodsReward.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.quests.rewards; 2 | 3 | import lombok.Getter; 4 | import org.bukkit.entity.Player; 5 | 6 | import java.util.function.Consumer; 7 | 8 | @Getter 9 | public class QuestMethodsReward implements QuestReward { 10 | private final Consumer runnable; 11 | 12 | /** 13 | * Create a new QuestItemReward. 14 | * 15 | * @param runnable The runnable 16 | */ 17 | public QuestMethodsReward(Consumer runnable) { 18 | this.runnable = runnable; 19 | } 20 | 21 | /** 22 | * Gives the reward to the specified player. 23 | *

24 | * The reward is split into stacks no larger than the item's maximum stack size. 25 | * If the player's inventory has enough space, each stack is added to the inventory. 26 | * Otherwise, any stack that cannot be fully accommodated is dropped at the player's location. 27 | * 28 | * @param player the target player for the reward. 29 | */ 30 | @Override 31 | public void giveReward(Player player) { 32 | runnable.accept(player); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/quests/rewards/QuestMoneyReward.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.quests.rewards; 2 | 3 | import fr.openmc.core.features.economy.EconomyManager; 4 | import fr.openmc.core.utils.messages.MessageType; 5 | import fr.openmc.core.utils.messages.MessagesManager; 6 | import fr.openmc.core.utils.messages.Prefix; 7 | import lombok.Getter; 8 | import net.kyori.adventure.text.Component; 9 | import org.bukkit.entity.Player; 10 | 11 | /** 12 | * Class representing a money reward for a quest. 13 | *

14 | * This class implements the QuestReward interface and provides functionality to give a specified amount of money to a player. 15 | */ 16 | @Getter 17 | public class QuestMoneyReward implements QuestReward { 18 | 19 | private final double amount; 20 | 21 | /** 22 | * Constructor for the QuestMoneyReward class. 23 | * 24 | * @param amount The amount of money to be rewarded. 25 | */ 26 | public QuestMoneyReward(double amount) { 27 | this.amount = amount; 28 | } 29 | 30 | /** 31 | * Gives the specified amount of money to the player. 32 | * 33 | * @param player The player to whom the reward will be given. 34 | */ 35 | @Override 36 | public void giveReward(Player player) { 37 | EconomyManager.addBalance(player.getUniqueId(), amount); 38 | MessagesManager.sendMessage( 39 | player, 40 | Component.text("§aVous avez reçu §e" + amount + EconomyManager.getEconomyIcon()), 41 | Prefix.QUEST, 42 | MessageType.SUCCESS, 43 | false 44 | ); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/quests/rewards/QuestReward.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.quests.rewards; 2 | 3 | import org.bukkit.entity.Player; 4 | 5 | /** 6 | * Interface representing a quest reward. 7 | * Implementations of this interface should define how to give the reward to a player. 8 | */ 9 | public interface QuestReward { 10 | /** 11 | * Gives the reward to the specified player. 12 | * 13 | * @param player The player to give the reward to. 14 | */ 15 | void giveReward(Player player); 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/settings/ValueType.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.settings; 2 | 3 | public enum ValueType { 4 | BOOLEAN, 5 | INTEGER, 6 | STRING, 7 | ENUM 8 | 9 | ; 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/settings/command/SettingsCommand.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.settings.command; 2 | 3 | import fr.openmc.core.features.settings.menu.PlayerSettingsMenu; 4 | import org.bukkit.entity.Player; 5 | import revxrsal.commands.annotation.Command; 6 | import revxrsal.commands.annotation.Description; 7 | import revxrsal.commands.bukkit.annotation.CommandPermission; 8 | 9 | public class SettingsCommand { 10 | 11 | @Command("settings") 12 | @Description("Affiche les paramètres de votre compte") 13 | @CommandPermission("omc.commands.settings") 14 | public static void settings(Player player) { 15 | new PlayerSettingsMenu(player).open(); 16 | } 17 | 18 | } -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/settings/models/PlayerSettingEntity.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.settings.models; 2 | 3 | import com.j256.ormlite.field.DatabaseField; 4 | import com.j256.ormlite.table.DatabaseTable; 5 | import fr.openmc.core.features.settings.SettingType; 6 | import lombok.Getter; 7 | import lombok.NoArgsConstructor; 8 | import lombok.Setter; 9 | 10 | import java.util.UUID; 11 | 12 | @DatabaseTable(tableName = "player_settings") 13 | @Getter 14 | @Setter 15 | @NoArgsConstructor 16 | public class PlayerSettingEntity { 17 | 18 | @DatabaseField(generatedId = true) 19 | private Long id; 20 | 21 | @DatabaseField(columnName = "playerUUID", canBeNull = false) 22 | private String playerUUID; 23 | 24 | @DatabaseField(columnName = "settingType", canBeNull = false) 25 | private String settingType; 26 | 27 | @DatabaseField(columnName = "settingValue", canBeNull = false) 28 | private String settingValue; 29 | 30 | public PlayerSettingEntity(UUID playerUUID, SettingType settingType, Object value) { 31 | this.playerUUID = playerUUID.toString(); 32 | this.settingType = settingType.name(); 33 | this.settingValue = value.toString(); 34 | } 35 | 36 | public SettingType getSettingTypeAsEnum() { 37 | return SettingType.valueOf(settingType); 38 | } 39 | 40 | public void updateValue(Object value) { 41 | this.settingValue = value.toString(); 42 | } 43 | } -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/settings/policy/CityPolicy.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.settings.policy; 2 | 3 | import lombok.Getter; 4 | 5 | @Getter 6 | public enum CityPolicy implements Policy { 7 | EVERYONE("§aTout le monde", "Accepter les demandes de tous les joueurs"), 8 | FRIENDS("§dAmis uniquement", "Accepter uniquement les demandes de mes amis"), 9 | NOBODY("§cPersonne", "Refuser toutes les demandes"); 10 | 11 | private final String displayName; 12 | private final String description; 13 | 14 | CityPolicy(String displayName, String description) { 15 | this.displayName = displayName; 16 | this.description = description; 17 | } 18 | } -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/settings/policy/FriendPolicy.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.settings.policy; 2 | 3 | import lombok.Getter; 4 | 5 | @Getter 6 | public enum FriendPolicy implements Policy { 7 | EVERYONE("§aTout le monde", "Accepter les demandes d'amis de tous les joueurs"), 8 | CITY_MEMBERS_ONLY("§6Membres de ma ville", "Accepter uniquement les demandes des membres de ma ville"), 9 | NOBODY("§cPersonne", "Refuser toutes les demandes d'amis"); 10 | 11 | private final String displayName; 12 | private final String description; 13 | 14 | FriendPolicy(String displayName, String description) { 15 | this.displayName = displayName; 16 | this.description = description; 17 | } 18 | } -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/settings/policy/GlobalPolicy.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.settings.policy; 2 | 3 | import lombok.Getter; 4 | 5 | @Getter 6 | public enum GlobalPolicy implements Policy { 7 | EVERYONE("§aTout le monde", "Visible par tous les joueurs"), 8 | FRIENDS("§dAmis uniquement", "Visible uniquement par mes amis"), 9 | CITY_MEMBERS("§6Membres de ma ville", "Visible par les membres de ma ville"), 10 | NOBODY("§cPersonne", "Information cachée à tous"); 11 | 12 | private final String displayName; 13 | private final String description; 14 | 15 | GlobalPolicy(String displayName, String description) { 16 | this.displayName = displayName; 17 | this.description = description; 18 | } 19 | } -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/settings/policy/Policy.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.settings.policy; 2 | 3 | public interface Policy { 4 | /** 5 | * Returns the display name of the policy. 6 | * 7 | * @return the display name 8 | */ 9 | String getDisplayName(); 10 | 11 | /** 12 | * Returns the description of the policy. 13 | * 14 | * @return the description 15 | */ 16 | String getDescription(); 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/tpa/TPAManager.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.tpa; 2 | 3 | import fr.openmc.core.OMCPlugin; 4 | import fr.openmc.core.CommandsManager; 5 | import fr.openmc.core.features.tpa.commands.TPACommand; 6 | import fr.openmc.core.features.tpa.commands.TPAcceptCommand; 7 | import fr.openmc.core.features.tpa.commands.TPCancelCommand; 8 | import fr.openmc.core.features.tpa.commands.TPDenyCommand; 9 | 10 | public class TPAManager { 11 | 12 | public TPAManager() { 13 | CommandsManager.getHandler().register( 14 | new TPAcceptCommand(), 15 | new TPACommand(OMCPlugin.getInstance()), 16 | new TPDenyCommand(), 17 | new TPCancelCommand() 18 | ); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/tpa/commands/TPCancelCommand.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.tpa.commands; 2 | 3 | import fr.openmc.core.features.tpa.TPAQueue; 4 | import fr.openmc.core.utils.messages.MessageType; 5 | import fr.openmc.core.utils.messages.MessagesManager; 6 | import fr.openmc.core.utils.messages.Prefix; 7 | import net.kyori.adventure.text.Component; 8 | import org.bukkit.entity.Player; 9 | import revxrsal.commands.annotation.Command; 10 | import revxrsal.commands.annotation.Named; 11 | import revxrsal.commands.annotation.Optional; 12 | import revxrsal.commands.bukkit.annotation.CommandPermission; 13 | 14 | public class TPCancelCommand { 15 | 16 | /** 17 | * Command to cancel a teleport request. 18 | * @param player The player who wants to cancel the request. 19 | */ 20 | @Command("tpcancel") 21 | @CommandPermission("omc.commands.tpa") 22 | public void tpCancel(Player player) { 23 | if (!TPAQueue.QUEUE.requesterHasPendingRequest(player)) { 24 | MessagesManager.sendMessage(player, Component.text("§4Vous n'avez aucune demande de téléportation en cours"), Prefix.OPENMC, MessageType.ERROR, false); 25 | return; 26 | } 27 | 28 | Player target = TPAQueue.QUEUE.getTargetByRequester(player); 29 | 30 | TPAQueue.QUEUE.removeRequest(player, target); 31 | MessagesManager.sendMessage(player, Component.text("§2Vous avez annulé votre demande de téléportation à §6" + target.getName()), Prefix.OPENMC, MessageType.SUCCESS, true); 32 | MessagesManager.sendMessage(target, Component.text("§3" + player.getName() + " §4a annulé sa demande de téléportation"), Prefix.OPENMC, MessageType.INFO, true); 33 | 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/updates/UpdateCommand.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.updates; 2 | 3 | import org.bukkit.entity.Player; 4 | 5 | import revxrsal.commands.annotation.Command; 6 | import revxrsal.commands.annotation.Description; 7 | import revxrsal.commands.bukkit.annotation.CommandPermission; 8 | 9 | public class UpdateCommand { 10 | 11 | @Command("omc version") 12 | @CommandPermission("omc.commands.version") 13 | @Description("Vous donne de l'information sur le version du plugin") 14 | private void version(Player player) { 15 | UpdateManager.sendUpdateMessage(player); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/features/updates/UpdateListener.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.features.updates; 2 | 3 | import org.bukkit.entity.Player; 4 | import org.bukkit.event.EventHandler; 5 | import org.bukkit.event.Listener; 6 | import org.bukkit.event.player.PlayerJoinEvent; 7 | 8 | public class UpdateListener implements Listener { 9 | 10 | @EventHandler 11 | public void onPlayerJoin(PlayerJoinEvent event) { 12 | final Player player = event.getPlayer(); 13 | 14 | UpdateManager.sendUpdateMessage(player); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/items/CustomItem.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.items; 2 | 3 | import dev.lone.itemsadder.api.CustomStack; 4 | import fr.openmc.core.utils.api.ItemsAdderApi; 5 | import lombok.Getter; 6 | import org.bukkit.inventory.ItemStack; 7 | 8 | public abstract class CustomItem { 9 | public abstract ItemStack getVanilla(); 10 | @Getter private final String name; 11 | 12 | public CustomItem(String name) { 13 | this.name = name; 14 | } 15 | 16 | public ItemStack getItemsAdder() { 17 | CustomStack stack = CustomStack.getInstance(getName()); 18 | return stack != null ? stack.getItemStack() : null; 19 | } 20 | 21 | @Override 22 | public boolean equals(Object anotherObject) { 23 | if (anotherObject instanceof ItemStack anotherItem) { 24 | CustomItem citem = CustomItemRegistry.getByItemStack(anotherItem); 25 | 26 | if (citem == null) return false; 27 | return citem.getName().equals(this.getName()); 28 | } 29 | 30 | if (anotherObject instanceof String name) { 31 | return this.getName().equals(name); 32 | } 33 | 34 | if (anotherObject instanceof CustomItem citem) { 35 | return citem.getName().equals(this.getName()); 36 | } 37 | 38 | return false; 39 | } 40 | 41 | /** 42 | * Order: 43 | * 1. ItemsAdder 44 | * 2. Vanilla 45 | * @return Best ItemStack to use for the server 46 | */ 47 | public ItemStack getBest() { 48 | return !ItemsAdderApi.hasItemAdder() || getItemsAdder() == null ? getVanilla() : getItemsAdder(); 49 | } 50 | } -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/listeners/ChronometerListener.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.listeners; 2 | 3 | import fr.openmc.api.chronometer.Chronometer; 4 | import org.bukkit.event.EventHandler; 5 | import org.bukkit.event.Listener; 6 | import org.bukkit.event.player.PlayerQuitEvent; 7 | 8 | public class ChronometerListener implements Listener { 9 | @EventHandler 10 | public void onDisconnection(PlayerQuitEvent e){ 11 | Chronometer.stopAllChronometer(e.getPlayer(), null, "%null%"); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/listeners/ClockInfos.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.listeners; 2 | 3 | import net.kyori.adventure.text.Component; 4 | import org.bukkit.Material; 5 | import org.bukkit.entity.Player; 6 | import org.bukkit.event.EventHandler; 7 | import org.bukkit.event.Listener; 8 | import org.bukkit.event.player.PlayerInteractEvent; 9 | import org.bukkit.inventory.PlayerInventory; 10 | 11 | /* 12 | * Repris de src/main/java/fr/communaywen/core/clockinfos/tasks/CompassClockTask.java 13 | * Travail original par Fnafgameur 14 | */ 15 | public class ClockInfos implements Listener { 16 | @EventHandler 17 | public void onPlayerInteract(PlayerInteractEvent event) { 18 | Player player = event.getPlayer(); 19 | PlayerInventory inv = player.getInventory(); 20 | 21 | if (inv.getItemInMainHand().getType() != Material.CLOCK) return; 22 | 23 | long daysPassed = player.getWorld().getFullTime() / 24000; 24 | long currentTime = player.getWorld().getTime(); 25 | long time = currentTime + (daysPassed * 24000); 26 | long hours = (time / 1000 + 6) % 24; 27 | long minutes = (time % 1000) * 60 / 1000; 28 | 29 | String minutesAsText = String.format("%02d", minutes); 30 | String hoursAsText = String.format("%02d", hours); 31 | 32 | // J12 03h49 33 | player.sendActionBar(Component.text("J"+daysPassed+" "+hoursAsText+"h"+minutesAsText)); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/listeners/InteractListener.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.listeners; 2 | 3 | import fr.openmc.core.features.city.ProtectionsManager; 4 | import fr.openmc.core.items.usable.CustomUsableItem; 5 | import fr.openmc.core.items.usable.CustomUsableItemRegistry; 6 | import org.bukkit.entity.Player; 7 | import org.bukkit.event.EventHandler; 8 | import org.bukkit.event.Listener; 9 | import org.bukkit.event.player.PlayerInteractEvent; 10 | import org.bukkit.inventory.ItemStack; 11 | 12 | public class InteractListener implements Listener { 13 | 14 | @EventHandler 15 | void onInteract(PlayerInteractEvent event) { 16 | Player player = event.getPlayer(); 17 | if (event.isCancelled()) return; 18 | if (event.getClickedBlock() == null) return; 19 | ProtectionsManager.verify(player, event, event.getClickedBlock().getLocation()); 20 | 21 | ItemStack itemInHand = player.getInventory().getItemInMainHand(); 22 | CustomUsableItem usableItem = CustomUsableItemRegistry.getByItemStack(itemInHand); 23 | 24 | if (usableItem != null) 25 | usableItem.handleInteraction(player, event); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/listeners/PlayerDeathListener.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.listeners; 2 | 3 | import fr.openmc.core.features.economy.EconomyManager; 4 | import fr.openmc.core.utils.messages.MessageType; 5 | import fr.openmc.core.utils.messages.MessagesManager; 6 | import fr.openmc.core.utils.messages.Prefix; 7 | import net.kyori.adventure.text.Component; 8 | import net.kyori.adventure.text.format.NamedTextColor; 9 | import org.bukkit.entity.Player; 10 | import org.bukkit.event.EventHandler; 11 | import org.bukkit.event.Listener; 12 | import org.bukkit.event.entity.PlayerDeathEvent; 13 | 14 | import static fr.openmc.core.features.economy.EconomyManager.*; 15 | 16 | public class PlayerDeathListener implements Listener { 17 | public static final double LOSS_MONEY = 0.35; 18 | 19 | @EventHandler(ignoreCancelled = true) 20 | public void onPlayerDead(PlayerDeathEvent event) { 21 | Player player = event.getPlayer(); 22 | double balance = getBalance(player.getUniqueId()); 23 | 24 | if (balance>0) { 25 | withdrawBalance(player.getUniqueId(), balance * LOSS_MONEY); 26 | MessagesManager.sendMessage(player, Component.text("Vous venez de mourrir avec §6" + getFormattedSimplifiedNumber(balance) + EconomyManager.getEconomyIcon() + "§f, vous avez perdu §6" + getFormattedSimplifiedNumber(balance * LOSS_MONEY) + EconomyManager.getEconomyIcon() + "\n§8*pensez à mettre votre argent dans la banque*"), Prefix.OPENMC, MessageType.INFO, false); 27 | } 28 | 29 | if (event.deathMessage() == null) return; 30 | MessagesManager.broadcastMessage(event.deathMessage().color(NamedTextColor.DARK_RED), Prefix.DEATH, MessageType.INFO); 31 | event.deathMessage(null); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/listeners/RespawnListener.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.listeners; 2 | 3 | import fr.openmc.core.commands.utils.SpawnManager; 4 | import org.bukkit.entity.Player; 5 | import org.bukkit.event.EventHandler; 6 | import org.bukkit.event.Listener; 7 | import org.bukkit.event.player.PlayerRespawnEvent; 8 | 9 | public class RespawnListener implements Listener { 10 | 11 | @EventHandler 12 | public void onRespawn(PlayerRespawnEvent event) { 13 | final Player player = event.getPlayer(); 14 | if (player.getRespawnLocation() != null) return; 15 | event.setRespawnLocation(SpawnManager.getSpawnLocation()); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/listeners/SessionsListener.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.listeners; 2 | 3 | import fr.openmc.core.features.analytics.Stats; 4 | import org.bukkit.event.EventHandler; 5 | import org.bukkit.event.Listener; 6 | import org.bukkit.event.player.PlayerJoinEvent; 7 | 8 | public class SessionsListener implements Listener { 9 | @EventHandler 10 | void onPlayerJoin(PlayerJoinEvent event) { 11 | Stats.SESSION.increment(event.getPlayer().getUniqueId()); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/utils/CacheOfflinePlayer.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.utils; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.OfflinePlayer; 5 | 6 | import java.util.HashMap; 7 | import java.util.Map; 8 | import java.util.UUID; 9 | 10 | public class CacheOfflinePlayer { 11 | private static final Map offlinePlayerCache = new HashMap<>(); 12 | 13 | /** 14 | * Donne l'OfflinePlayer s'il est déjà mis en cache, sinon il exécute la méthode basique 15 | */ 16 | public static OfflinePlayer getOfflinePlayer(UUID uuid) { 17 | return offlinePlayerCache.computeIfAbsent(uuid, Bukkit::getOfflinePlayer); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/utils/ChunkInfo.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.utils; 2 | 3 | import fr.openmc.core.features.city.City; 4 | 5 | public record ChunkInfo(City city, boolean isProtected) { } -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/utils/ChunkPos.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.utils; 2 | 3 | public class ChunkPos { 4 | final int x, z; 5 | public ChunkPos(int x, int z) { this.x = x; this.z = z; } 6 | 7 | @Override 8 | public boolean equals(Object o) { 9 | if (this == o) return true; 10 | if (o == null || getClass() != o.getClass()) return false; 11 | ChunkPos chunkPos = (ChunkPos) o; 12 | return x == chunkPos.x && z == chunkPos.z; 13 | } 14 | 15 | @Override 16 | public int hashCode() { 17 | return 31 * x + z; 18 | } 19 | 20 | @Override 21 | public String toString() { 22 | return x + "," + z; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/utils/DirectionUtils.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.utils; 2 | 3 | import org.bukkit.Location; 4 | import org.bukkit.entity.Player; 5 | import org.bukkit.util.Vector; 6 | 7 | public class DirectionUtils { 8 | /** 9 | * Retourne une flèche directionnelle (↑, ↗, →, etc.) indiquant la direction de point1 à point2. 10 | * 11 | * @param player Le joueur 12 | * @param target Position cible (par exemple, la mascotte) 13 | * @return Emoji directionnel 14 | */ 15 | public static String getDirectionArrow(Player player, Location target) { 16 | Vector delta = target.toVector().subtract(player.getLocation().toVector()); 17 | delta.setY(0); 18 | if (delta.lengthSquared() == 0) { 19 | return "•"; 20 | } 21 | 22 | double yawRad = Math.toRadians(player.getLocation().getYaw()); 23 | Vector forward = new Vector(-Math.sin(yawRad), 0, Math.cos(yawRad)); 24 | delta = delta.normalize(); 25 | double dot = forward.dot(delta); 26 | Vector cross = forward.clone().crossProduct(delta); 27 | double angle = Math.toDegrees(Math.atan2(-cross.getY(), dot)); 28 | 29 | if (angle > 157.5 || angle <= -157.5) return "↓"; 30 | if (angle > 112.5) return "↘"; 31 | if (angle > 67.5) return "→"; 32 | if (angle > 22.5) return "↗"; 33 | if (angle > -22.5) return "↑"; 34 | if (angle > -67.5) return "↖"; 35 | if (angle > -112.5) return "←"; 36 | return "↙"; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/utils/DiscordWebhook.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.utils; 2 | 3 | import javax.net.ssl.HttpsURLConnection; 4 | import java.io.OutputStream; 5 | import java.net.URI; 6 | import java.net.URL; 7 | import java.nio.charset.StandardCharsets; 8 | 9 | public class DiscordWebhook { 10 | 11 | /** 12 | * Envoie un message vers un webhook Discord via POST JSON. 13 | * 14 | * @param webhookUrl URL complète du webhook (https://discord.com/api/webhooks/ID/TOKEN). 15 | * @param message Contenu du message à envoyer. 16 | * @throws Exception en cas d’erreur de connexion ou d’I/O. 17 | */ 18 | public static void sendMessage(String webhookUrl, String message) throws Exception { 19 | URL url = new URI(webhookUrl).toURL(); 20 | HttpsURLConnection conn = (HttpsURLConnection) url.openConnection(); 21 | conn.setRequestMethod("POST"); 22 | conn.setRequestProperty("Content-Type", "application/json"); 23 | conn.setDoOutput(true); 24 | 25 | String jsonPayload = String.format("{\"content\":\"%s\"}", message); 26 | try (OutputStream os = conn.getOutputStream()) { 27 | os.write(jsonPayload.getBytes(StandardCharsets.UTF_8)); 28 | } 29 | 30 | int status = conn.getResponseCode(); 31 | if (status != 204) { 32 | throw new RuntimeException("Échec du webhook, code HTTP : " + status); 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/utils/LocationUtils.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.utils; 2 | 3 | import org.bukkit.Location; 4 | import org.bukkit.World; 5 | import org.bukkit.block.Block; 6 | 7 | public class LocationUtils { 8 | public static Location getSafeNearbySurface(Location location, int radius) { 9 | World world = location.getWorld(); 10 | int baseY = location.getBlockY(); 11 | int maxY = Math.min(baseY + 10, world.getMaxHeight() - 2); 12 | int minY = Math.max(baseY - 10, world.getMinHeight() + 1); 13 | 14 | for (int dx = -radius; dx <= radius; dx++) { 15 | for (int dz = -radius; dz <= radius; dz++) { 16 | int baseX = location.getBlockX() + dx; 17 | int baseZ = location.getBlockZ() + dz; 18 | 19 | for (int dy = 0; dy <= (maxY - minY); dy++) { 20 | int offsetY = (dy % 2 == 0) ? dy / 2 : -(dy / 2); 21 | int y = baseY + offsetY; 22 | if (y > maxY || y < minY) continue; 23 | 24 | Block under = world.getBlockAt(baseX, y - 1, baseZ); 25 | Block feet = world.getBlockAt(baseX, y, baseZ); 26 | Block head = world.getBlockAt(baseX, y + 1, baseZ); 27 | 28 | if (!under.isPassable() && feet.isPassable() && head.isPassable()) { 29 | return new Location(world, baseX + 0.5, y, baseZ + 0.5); 30 | } 31 | } 32 | } 33 | } 34 | 35 | return new Location( 36 | world, 37 | location.getBlockX() + 0.5, 38 | location.getBlockY(), 39 | location.getBlockZ() + 0.5 40 | ); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/utils/MotdUtils.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.utils; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.configuration.file.YamlConfiguration; 5 | import org.bukkit.scheduler.BukkitRunnable; 6 | 7 | import fr.openmc.core.OMCPlugin; 8 | import net.kyori.adventure.text.Component; 9 | 10 | import java.io.File; 11 | import java.util.List; 12 | import java.util.Map; 13 | import java.util.Random; 14 | 15 | public class MotdUtils { 16 | private final YamlConfiguration motdConfig; 17 | private static Component motd; 18 | 19 | public MotdUtils() { 20 | File motdFile = new File(OMCPlugin.getInstance().getDataFolder() + "/data", "motd.yml"); 21 | 22 | if(!motdFile.exists()) { 23 | motdFile.getParentFile().mkdirs(); 24 | OMCPlugin.getInstance().saveResource("data/motd.yml", false); 25 | } 26 | 27 | motdConfig = YamlConfiguration.loadConfiguration(motdFile); 28 | 29 | new BukkitRunnable() { 30 | @Override 31 | public void run() { 32 | List> motds = motdConfig.getMapList("motds"); 33 | 34 | int randomIndex = new Random().nextInt(motds.size()); 35 | Map motdData = motds.get(randomIndex); 36 | 37 | String line1 = (String) (motdData).get("line1"); 38 | String line2 = (String) (motdData).get("line2"); 39 | 40 | 41 | motd=Component.text(line1 + "\n" + line2); 42 | Bukkit.getServer().motd(motd); 43 | } 44 | }.runTaskTimer(OMCPlugin.getInstance(), 0L, 12000L); // 12000 ticks = 10 minutes 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/utils/PlayerNameCache.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.utils; 2 | 3 | import org.bukkit.OfflinePlayer; 4 | 5 | import java.util.HashMap; 6 | import java.util.Map; 7 | import java.util.UUID; 8 | 9 | public class PlayerNameCache { 10 | private static final Map nameCache = new HashMap<>(); 11 | 12 | public static String getName(UUID uuid) { 13 | return nameCache.computeIfAbsent(uuid, id -> { 14 | OfflinePlayer player = CacheOfflinePlayer.getOfflinePlayer(id); 15 | return player.getName() != null ? player.getName() : "Inconnu"; 16 | }); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/utils/PlayerUtils.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.utils; 2 | 3 | import fr.openmc.core.OMCPlugin; 4 | import fr.openmc.core.features.settings.PlayerSettingsManager; 5 | import fr.openmc.core.features.settings.SettingType; 6 | import me.clip.placeholderapi.PlaceholderAPI; 7 | import org.bukkit.Location; 8 | import org.bukkit.World; 9 | import org.bukkit.entity.Player; 10 | import org.bukkit.scheduler.BukkitRunnable; 11 | 12 | import java.util.Random; 13 | 14 | public class PlayerUtils { 15 | public static void sendFadeTitleTeleport(Player player, Location location) { 16 | if (PlayerSettingsManager.getPlayerSettings(player.getUniqueId()).getSetting(SettingType.TELEPORT_TITLE_FADE)) { 17 | player.sendTitle(PlaceholderAPI.setPlaceholders(player, "§0%img_tp_effect%"), "§a§lTéléportation...", 20, 10, 10); 18 | new BukkitRunnable() { 19 | @Override 20 | public void run() { 21 | player.teleport(location); 22 | } 23 | }.runTaskLater(OMCPlugin.getInstance(), 10); 24 | } else { 25 | player.teleport(location); 26 | } 27 | } 28 | 29 | public static void teleportNear(Player player, Location center, double radius) { 30 | World world = center.getWorld(); 31 | Random random = new Random(); 32 | 33 | double angle = random.nextDouble() * 2 * Math.PI; 34 | double distance = random.nextDouble() * radius; 35 | 36 | double x = center.getX() + Math.cos(angle) * distance; 37 | double z = center.getZ() + Math.sin(angle) * distance; 38 | int y = world.getHighestBlockYAt((int) x, (int) z); 39 | 40 | Location target = new Location(world, x, y, z); 41 | 42 | player.teleportAsync(target.add(0.5, 1, 0.5)); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/utils/Queue.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.utils; 2 | 3 | import lombok.Getter; 4 | 5 | import java.util.LinkedHashMap; 6 | import java.util.Map; 7 | 8 | @Getter 9 | public class Queue { 10 | 11 | private final LinkedHashMap queue; 12 | 13 | public Queue(int size) { 14 | this.queue = new LinkedHashMap() { 15 | @Override 16 | protected boolean removeEldestEntry(final Map.Entry eldest) { 17 | return size() > size; 18 | } 19 | }; 20 | } 21 | 22 | public void add(K key, V value) { 23 | queue.put(key, value); 24 | } 25 | 26 | public void remove(K key) { 27 | queue.remove(key); 28 | } 29 | 30 | public V get(K key) { 31 | return queue.get(key); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/utils/api/FancyNpcsApi.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.utils.api; 2 | 3 | import org.bukkit.Bukkit; 4 | 5 | public class FancyNpcsApi { 6 | private static boolean hasFancyNpc = false; 7 | 8 | public FancyNpcsApi() { 9 | hasFancyNpc = Bukkit.getPluginManager().isPluginEnabled("FancyNpcs"); 10 | } 11 | 12 | /** 13 | * Retourne si l'instance a FancyNpc 14 | */ 15 | public static boolean hasFancyNpc() { 16 | return hasFancyNpc; 17 | } 18 | 19 | /** 20 | * Set if the instance has FancyNpc 21 | * 22 | * @param hasFancyNpc true if the instance has FancyNpc, false otherwise 23 | */ 24 | public static void setHasFancyNpc(boolean hasFancyNpc) { 25 | FancyNpcsApi.hasFancyNpc = hasFancyNpc; 26 | } 27 | } -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/utils/api/ItemsAdderApi.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.utils.api; 2 | 3 | import org.bukkit.Bukkit; 4 | 5 | public class ItemsAdderApi { 6 | private static boolean hasItemAdder; 7 | 8 | public ItemsAdderApi() { 9 | hasItemAdder = Bukkit.getPluginManager().isPluginEnabled("ItemsAdder");; 10 | } 11 | 12 | /** 13 | * Retourne si l'instance a ItemAdder 14 | */ 15 | public static boolean hasItemAdder() { 16 | return hasItemAdder; 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/utils/api/PapiApi.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.utils.api; 2 | 3 | import org.bukkit.Bukkit; 4 | 5 | public class PapiApi { 6 | private static boolean hasPAPI; 7 | 8 | public PapiApi() { 9 | hasPAPI = Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null; 10 | } 11 | 12 | /** 13 | * Retourne si l'instance a PlaceholderAPI 14 | */ 15 | public static boolean hasPAPI() { 16 | return hasPAPI; 17 | } 18 | 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/utils/customfonts/CustomFonts.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.utils.customfonts; 2 | 3 | import fr.openmc.core.utils.api.ItemsAdderApi; 4 | 5 | public abstract class CustomFonts { 6 | /** 7 | * use exemple : CustomFonts.getBest("omc_homes:bin", "🗑️") 8 | * 9 | * @param namespaceID the namespaceID of the font 10 | * @param baseFont the base font 11 | * @return Best Font to use for the server 12 | */ 13 | public static String getBest(String namespaceID, String baseFont) { 14 | String font = null; 15 | if (ItemsAdderApi.hasItemAdder()) font = Fonts.getFont(namespaceID); 16 | 17 | if (font == null) { 18 | font = baseFont; 19 | } 20 | 21 | return font; 22 | } 23 | } -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/utils/customfonts/Fonts.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.utils.customfonts; 2 | 3 | import dev.lone.itemsadder.api.FontImages.FontImageWrapper; 4 | 5 | public class Fonts { 6 | public static String getFont(String namespaceID){ 7 | return "§r" + new FontImageWrapper(namespaceID).getString(); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/utils/messages/MessageType.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.utils.messages; 2 | 3 | import lombok.Getter; 4 | import org.bukkit.Sound; 5 | 6 | @Getter 7 | public enum MessageType { 8 | ERROR("§c❗", Sound.BLOCK_NOTE_BLOCK_BASS), 9 | WARNING("§6⚠", Sound.BLOCK_NOTE_BLOCK_HARP), 10 | SUCCESS("§a✔", Sound.BLOCK_NOTE_BLOCK_PLING), 11 | INFO("§bℹ", Sound.BLOCK_NOTE_BLOCK_BIT), 12 | NONE("", null) 13 | ; 14 | 15 | private final String prefix; 16 | private final Sound sound; 17 | 18 | MessageType(String prefix, Sound sound) { 19 | this.prefix = prefix; 20 | this.sound = sound; 21 | } 22 | } -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/utils/messages/Prefix.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.utils.messages; 2 | 3 | import lombok.Getter; 4 | 5 | /** 6 | * Enum representing various prefixes for messages. 7 | * Each prefix is associated with a formatted string using custom colors and fonts. 8 | */ 9 | public enum Prefix { 10 | 11 | // Font: https://lingojam.com/MinecraftSmallFont 12 | // For gradient color: https://www.birdflop.com/resources/rgb/ 13 | // Color format: MiniMessage 14 | 15 | OPENMC("ᴏᴘᴇɴᴍᴄ"), 16 | STAFF("ѕᴛᴀꜰꜰ"), 17 | CITY("ᴄɪᴛʏ"), 18 | CONTEST("ᴄᴏɴᴛᴇѕᴛ"), 19 | HOME("ʜᴏᴍᴇ"), 20 | FRIEND("ꜰʀɪᴇɴᴅ"), 21 | MAYOR("ᴍᴀʏᴏʀ"), 22 | QUEST("ǫᴜᴇѕᴛ"), 23 | BANK("ʙᴀɴᴋ"), 24 | ENTREPRISE("ᴇɴᴛʀᴇᴘʀɪѕᴇ"), // a changer si ça ne correspond pas 25 | SHOP("ѕʜᴏᴘ"), 26 | ADMINSHOP("ᴀᴅᴍɪɴꜱʜᴏᴘ"), 27 | ACCOUTDETECTION("ᴀᴄᴄᴏᴜɴᴛ ᴅᴇᴛᴇᴄᴛɪᴏɴ"), 28 | DEATH("☠"), 29 | SETTINGS("ѕᴇᴛᴛɪɴɢѕ"), 30 | MILLESTONE("ᴍɪʟʟᴇѕᴛᴏɴᴇ") 31 | 32 | ; 33 | 34 | @Getter private final String prefix; 35 | Prefix(String prefix) { 36 | this.prefix = prefix; 37 | } 38 | } -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/utils/serializer/BukkitSerializer.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.utils.serializer; 2 | 3 | import lombok.Cleanup; 4 | import org.bukkit.inventory.ItemStack; 5 | import org.bukkit.util.io.BukkitObjectInputStream; 6 | import org.bukkit.util.io.BukkitObjectOutputStream; 7 | 8 | import java.io.ByteArrayInputStream; 9 | import java.io.ByteArrayOutputStream; 10 | import java.io.IOException; 11 | 12 | public class BukkitSerializer { 13 | public static byte[] serializeItemStacks(ItemStack[] inv) throws IOException { 14 | @Cleanup ByteArrayOutputStream os = new ByteArrayOutputStream(); 15 | @Cleanup BukkitObjectOutputStream bos = new BukkitObjectOutputStream(os); 16 | bos.writeObject(inv); 17 | return os.toByteArray(); 18 | } 19 | 20 | public static ItemStack[] deserializeItemStacks(byte[] b) throws Exception { 21 | @Cleanup ByteArrayInputStream bais = new ByteArrayInputStream(b); 22 | @Cleanup BukkitObjectInputStream bois = new BukkitObjectInputStream(bais); 23 | return (ItemStack[]) bois.readObject(); 24 | } 25 | } -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/utils/world/WorldUtils.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.utils.world; 2 | 3 | import org.bukkit.entity.Player; 4 | 5 | public class WorldUtils { 6 | 7 | public static Yaw getYaw(Player p) { 8 | float yaw = p.getLocation().getYaw(); 9 | yaw = (yaw % 360 + 360) % 360; // true modulo, as javas modulo is weird for negative values 10 | if (yaw > 135 || yaw < -135) { 11 | return Yaw.NORTH; 12 | } else if (yaw < -45) { 13 | return Yaw.EAST; 14 | } else if (yaw > 45) { 15 | return Yaw.WEST; 16 | } else { 17 | return Yaw.SOUTH; 18 | } 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/fr/openmc/core/utils/world/Yaw.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.utils.world; 2 | 3 | import org.bukkit.block.BlockFace; 4 | 5 | public enum Yaw { 6 | 7 | NORTH, 8 | EAST, 9 | SOUTH, 10 | WEST; 11 | 12 | public Yaw getOpposite() { 13 | return switch (this) { 14 | case NORTH -> SOUTH; 15 | case EAST -> WEST; 16 | case SOUTH -> NORTH; 17 | case WEST -> EAST; 18 | }; 19 | } 20 | 21 | public BlockFace toBlockFace() { 22 | return switch (this) { 23 | case NORTH -> BlockFace.NORTH; 24 | case EAST -> BlockFace.EAST; 25 | case SOUTH -> BlockFace.SOUTH; 26 | case WEST -> BlockFace.WEST; 27 | }; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/main/resources/config.yml: -------------------------------------------------------------------------------- 1 | ##### 2 | # Database 3 | ##### 4 | database: 5 | url: "jdbc:mysql://host:port/openmc" 6 | username: "" 7 | password: "" 8 | 9 | features: 10 | analytics: true 11 | transactions: true 12 | 13 | chat: 14 | # {prefix}, {suffix}, {name}, {message} 15 | message: "&r{prefix} {name}&8: &f{message}" 16 | 17 | # Montant d'argent donné à un joueur lors de sa première connexion 18 | money-on-first-join: 500 19 | 20 | ##### 21 | # Paramètres pour un environnement de production 22 | ##### 23 | homepage: "https://openmc.fr/" 24 | discord: "https://aywen.fr/discord/" 25 | blog: "https://blog.openmc.fr/" 26 | wiki: "https://wiki.openmc.fr/" 27 | repoV2: "https://github.com/ServerOpenMC/PluginV2" 28 | -------------------------------------------------------------------------------- /src/main/resources/data/accountdetection.yml: -------------------------------------------------------------------------------- 1 | anti-vpn: true 2 | anti-double-account: true 3 | discord-webhook: https://discord.com/api/webhooks/ID/TOKEN 4 | exempted-players: 5 | - dfa5846a-6f55-4407-9eb7-d06aafdbc804 # Moi 6 | - d2ca5e0f-2d36-4ba1-8d0f-0c277a1da6ef # Mon double compte ;) -------------------------------------------------------------------------------- /src/main/resources/data/bossbars.yml: -------------------------------------------------------------------------------- 1 | messages: 2 | - "Bienvenue sur OpenMC !" 3 | - "Astuce : Utilisez /leaderboard pour voir les classements !" 4 | - "Événement en cours : UPDATE V2 !" 5 | - "Astuce : Utilisez /omcbossbar ou /bb pour activer/désactiver la bossbar !" 6 | - "Rejoignez le discord pour contribuer au développement !" -------------------------------------------------------------------------------- /src/main/resources/data/leaderboards.yml: -------------------------------------------------------------------------------- 1 | contributors-location: 2 | ==: org.bukkit.Location 3 | world: world 4 | x: 0.0 5 | y: 0.0 6 | z: 0.0 7 | pitch: 0.0 8 | yaw: 0.0 9 | money-location: 10 | ==: org.bukkit.Location 11 | world: world 12 | x: 0.0 13 | y: 0.0 14 | z: 0.0 15 | pitch: 0.0 16 | yaw: 0.0 17 | ville-money-location: 18 | ==: org.bukkit.Location 19 | world: world 20 | x: 0.0 21 | y: 0.0 22 | z: 0.0 23 | pitch: 0.0 24 | yaw: 0.0 25 | playtime-location: 26 | ==: org.bukkit.Location 27 | world: world 28 | x: 0.0 29 | y: 0.0 30 | z: 0.0 31 | pitch: 0.0 32 | yaw: 0.0 33 | scale: 0.75 -------------------------------------------------------------------------------- /src/main/resources/data/mascots.yml: -------------------------------------------------------------------------------- 1 | #--------------------CONFIGURATION DES MASCOTS----------------------------- 2 | # La Liste des Mascots 3 | # sert de data container pour les free claims 4 | -------------------------------------------------------------------------------- /src/main/resources/data/motd.yml: -------------------------------------------------------------------------------- 1 | ##### 2 | # MOTD 3 | ##### 4 | motds: 5 | - motd1: 6 | line1: "§d§lOPENMC V2 §r§8- §7Le serveur Open Source §8- §d1.21.5" 7 | line2: " §6§lCONTEST UPDATE §3§lCITY UPDATE §d§lV2 UPDATE " 8 | - motd2: 9 | line1: "§d§lOPENMC V2 §r§8- §7Le serveur Open Source §8- §d1.21.5" 10 | line2: " §3§lV2 UPDATE " -------------------------------------------------------------------------------- /src/main/resources/data/rtp.yml: -------------------------------------------------------------------------------- 1 | max-radius: 10000 2 | min-radius: 2000 3 | # Par rapport au spawn 4 | max-tries: 3 5 | rtp-cooldown: 3600 # 1h -------------------------------------------------------------------------------- /src/main/resources/data/spawn.yml: -------------------------------------------------------------------------------- 1 | spawn: 2 | world: world # Nom du monde 3 | x: 0.0 # Coordonnées X 4 | y: 0.0 # Coordonnées Y 5 | z: 0.0 # Coordonnées Z 6 | yaw: 0.0 # Coordonnées Yaw 7 | pitch: 0.0 # Coordonnées Pitch -------------------------------------------------------------------------------- /src/main/resources/plugin.yml: -------------------------------------------------------------------------------- 1 | name: OpenMC 2 | version: ${version} 3 | main: fr.openmc.core.OMCPlugin 4 | api-version: '1.21.5' 5 | 6 | depend: 7 | - WorldEdit 8 | 9 | softdepend: 10 | - FancyNpcs 11 | - PlaceholderAPI 12 | - LuckPerms 13 | - ItemsAdder 14 | - WorldGuard 15 | - ProtocolLib 16 | 17 | prefix: OMC 18 | authors: [ La communauté ] 19 | description: Nouveau plugin d'OpenMC 20 | website: https://openmc.fr 21 | 22 | permissions: 23 | omc.commands.*: 24 | description: "Donne l'accès au commandes" 25 | default: true 26 | omc.admins.commands.*: 27 | description: "Donne l'accès aux commandes d'administration" 28 | default: op 29 | -------------------------------------------------------------------------------- /src/main/resources/translations/fr.yml: -------------------------------------------------------------------------------- 1 | messages: 2 | general: 3 | playtime: "Vous avez {playTime} §7de temps de jeu." 4 | -------------------------------------------------------------------------------- /src/test/java/fr/openmc/core/OMCPluginTest.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core; 2 | 3 | import lombok.Getter; 4 | import org.junit.jupiter.api.AfterEach; 5 | import org.junit.jupiter.api.Assertions; 6 | import org.junit.jupiter.api.BeforeEach; 7 | import org.junit.jupiter.api.DisplayName; 8 | import org.junit.jupiter.api.Test; 9 | 10 | import org.mockbukkit.mockbukkit.ServerMock; 11 | import org.mockbukkit.mockbukkit.MockBukkit; 12 | 13 | public class OMCPluginTest { 14 | 15 | public OMCPlugin plugin; 16 | public static ServerMock server; 17 | 18 | @BeforeEach 19 | public void setUp() { 20 | server = MockBukkit.mock(); 21 | 22 | server.addSimpleWorld("world"); 23 | 24 | plugin = MockBukkit.load(OMCPlugin.class); 25 | } 26 | 27 | @AfterEach 28 | public void tearDown() { 29 | MockBukkit.unmock(); 30 | } 31 | 32 | @Test 33 | @DisplayName("Test if plugin is load") 34 | public void testPluginIsEnabled() { 35 | Assertions.assertTrue(plugin.isEnabled()); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/test/java/fr/openmc/core/utils/DateUtilsTest.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.utils; 2 | 3 | import org.junit.jupiter.api.*; 4 | 5 | public class DateUtilsTest { 6 | 7 | @Test 8 | @DisplayName("Time to Ticks") 9 | public void testConvertTime() { 10 | Assertions.assertEquals( 11 | "20m", 12 | DateUtils.convertTime(24000) 13 | ); 14 | } 15 | 16 | } -------------------------------------------------------------------------------- /src/test/java/fr/openmc/core/utils/ItemsUtilTest.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.utils; 2 | 3 | import org.bukkit.Material; 4 | import org.bukkit.inventory.ItemStack; 5 | import org.junit.jupiter.api.Assertions; 6 | import org.junit.jupiter.api.DisplayName; 7 | import org.junit.jupiter.api.Test; 8 | 9 | public class ItemsUtilTest { 10 | 11 | @Test 12 | @DisplayName("getItemTranslation with ItemStack") 13 | public void testGetTranslationWithStack() { 14 | Assertions.assertEquals( 15 | "block.minecraft.chest", 16 | ItemUtils.getItemTranslation(new ItemStack(Material.CHEST)).key() 17 | ); 18 | } 19 | 20 | @Test 21 | @DisplayName("getItemTranslation with Material") 22 | public void testGetTranslationWithMaterial() { 23 | Assertions.assertEquals( 24 | "block.minecraft.dirt", 25 | ItemUtils.getItemTranslation(Material.DIRT).key() 26 | ); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/test/java/fr/openmc/core/utils/MotdUtilsTest.java: -------------------------------------------------------------------------------- 1 | package fr.openmc.core.utils; 2 | 3 | import fr.openmc.core.OMCPlugin; 4 | import net.kyori.adventure.text.Component; 5 | import net.kyori.adventure.text.TextComponent; 6 | 7 | import org.junit.jupiter.api.AfterEach; 8 | import org.junit.jupiter.api.Assertions; 9 | import org.junit.jupiter.api.BeforeEach; 10 | import org.junit.jupiter.api.DisplayName; 11 | import org.junit.jupiter.api.Test; 12 | 13 | import org.mockbukkit.mockbukkit.ServerMock; 14 | import org.mockbukkit.mockbukkit.MockBukkit; 15 | 16 | public class MotdUtilsTest { 17 | 18 | private ServerMock server; 19 | 20 | @BeforeEach 21 | public void setUp() { 22 | server = MockBukkit.mock(); 23 | 24 | server.addSimpleWorld("world"); 25 | 26 | MockBukkit.load(OMCPlugin.class); 27 | } 28 | 29 | @AfterEach 30 | public void tearDown() { 31 | MockBukkit.unmock(); 32 | } 33 | 34 | private String getComponentContent(Component component) { 35 | return ((TextComponent) component).content(); 36 | } 37 | 38 | @Test 39 | @DisplayName("MOTD switch") 40 | public void testMOTD() { 41 | String motd = getComponentContent(server.motd()); 42 | 43 | new MotdUtils(); 44 | server.getScheduler().performTicks(12001L); 45 | 46 | Assertions.assertNotEquals(getComponentContent(server.motd()), motd); 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /src/test/resources/config.yml: -------------------------------------------------------------------------------- 1 | ##### 2 | # Database 3 | ##### 4 | database: 5 | url: "jdbc:h2:~/test" 6 | username: "" 7 | password: "" 8 | 9 | features: 10 | analytics: true 11 | transactions: true 12 | 13 | ##### 14 | # Paramètres pour un environnement de production 15 | ##### 16 | homepage: "https://openmc.fr/" 17 | discord: "https://discord.gg/aywen/" 18 | blog: "https://blog.openmc.fr/" 19 | -------------------------------------------------------------------------------- /src/test/resources/plugin.yml: -------------------------------------------------------------------------------- 1 | name: OpenMC 2 | version: ${version} 3 | main: fr.openmc.core.TestPlugin 4 | api-version: '1.21.5' 5 | prefix: OMC 6 | -------------------------------------------------------------------------------- /third_party_licenses/SignGUI_LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 Rapha149 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. --------------------------------------------------------------------------------