├── .gitattributes ├── .github ├── FUNDING.yml └── workflows │ └── maven.yml ├── .gitignore ├── Changelog.txt ├── Changelog_2.1.0.md ├── LICENSE ├── README.md ├── pom.xml ├── src ├── main │ ├── assembly │ │ └── package.xml │ ├── java │ │ ├── META-INF │ │ │ └── MANIFEST.MF │ │ ├── com │ │ │ └── gmail │ │ │ │ └── nossr50 │ │ │ │ ├── api │ │ │ │ ├── AbilityAPI.java │ │ │ │ ├── ChatAPI.java │ │ │ │ ├── DatabaseAPI.java │ │ │ │ ├── ExperienceAPI.java │ │ │ │ ├── FakeBlockBreakEventType.java │ │ │ │ ├── ItemSpawnReason.java │ │ │ │ ├── PartyAPI.java │ │ │ │ ├── SkillAPI.java │ │ │ │ ├── TreeFellerBlockBreakEvent.java │ │ │ │ └── exceptions │ │ │ │ │ ├── IncompleteNamespacedKeyRegister.java │ │ │ │ │ ├── InvalidFormulaTypeException.java │ │ │ │ │ ├── InvalidPlayerException.java │ │ │ │ │ ├── InvalidSkillException.java │ │ │ │ │ ├── InvalidXPGainReasonException.java │ │ │ │ │ ├── McMMOPlayerNotFoundException.java │ │ │ │ │ └── ValueOutOfBoundsException.java │ │ │ │ ├── chat │ │ │ │ ├── ChatManager.java │ │ │ │ ├── SamePartyPredicate.java │ │ │ │ ├── author │ │ │ │ │ ├── AbstractPlayerAuthor.java │ │ │ │ │ ├── Author.java │ │ │ │ │ ├── ConsoleAuthor.java │ │ │ │ │ └── PlayerAuthor.java │ │ │ │ ├── mailer │ │ │ │ │ ├── AbstractChatMailer.java │ │ │ │ │ ├── AdminChatMailer.java │ │ │ │ │ ├── ChatMailer.java │ │ │ │ │ └── PartyChatMailer.java │ │ │ │ └── message │ │ │ │ │ ├── AbstractChatMessage.java │ │ │ │ │ ├── AdminChatMessage.java │ │ │ │ │ ├── ChatMessage.java │ │ │ │ │ └── PartyChatMessage.java │ │ │ │ ├── commands │ │ │ │ ├── CommandManager.java │ │ │ │ ├── McabilityCommand.java │ │ │ │ ├── McconvertCommand.java │ │ │ │ ├── McgodCommand.java │ │ │ │ ├── McmmoCommand.java │ │ │ │ ├── McnotifyCommand.java │ │ │ │ ├── McrefreshCommand.java │ │ │ │ ├── McscoreboardCommand.java │ │ │ │ ├── ToggleCommand.java │ │ │ │ ├── XprateCommand.java │ │ │ │ ├── admin │ │ │ │ │ ├── CompatibilityCommand.java │ │ │ │ │ ├── DropTreasureCommand.java │ │ │ │ │ ├── McmmoReloadLocaleCommand.java │ │ │ │ │ └── PlayerDebugCommand.java │ │ │ │ ├── chat │ │ │ │ │ ├── AdminChatCommand.java │ │ │ │ │ ├── McChatSpy.java │ │ │ │ │ └── PartyChatCommand.java │ │ │ │ ├── database │ │ │ │ │ ├── ConvertDatabaseCommand.java │ │ │ │ │ ├── McpurgeCommand.java │ │ │ │ │ ├── McremoveCommand.java │ │ │ │ │ └── MmoshowdbCommand.java │ │ │ │ ├── experience │ │ │ │ │ ├── AddlevelsCommand.java │ │ │ │ │ ├── AddxpCommand.java │ │ │ │ │ ├── ConvertExperienceCommand.java │ │ │ │ │ ├── ExperienceCommand.java │ │ │ │ │ ├── MmoeditCommand.java │ │ │ │ │ └── SkillresetCommand.java │ │ │ │ ├── hardcore │ │ │ │ │ ├── HardcoreCommand.java │ │ │ │ │ ├── HardcoreModeCommand.java │ │ │ │ │ └── VampirismCommand.java │ │ │ │ ├── party │ │ │ │ │ ├── PartyAcceptCommand.java │ │ │ │ │ ├── PartyChangeOwnerCommand.java │ │ │ │ │ ├── PartyChangePasswordCommand.java │ │ │ │ │ ├── PartyCommand.java │ │ │ │ │ ├── PartyCreateCommand.java │ │ │ │ │ ├── PartyDisbandCommand.java │ │ │ │ │ ├── PartyHelpCommand.java │ │ │ │ │ ├── PartyInfoCommand.java │ │ │ │ │ ├── PartyInviteCommand.java │ │ │ │ │ ├── PartyItemShareCommand.java │ │ │ │ │ ├── PartyJoinCommand.java │ │ │ │ │ ├── PartyKickCommand.java │ │ │ │ │ ├── PartyLockCommand.java │ │ │ │ │ ├── PartyQuitCommand.java │ │ │ │ │ ├── PartyRenameCommand.java │ │ │ │ │ ├── PartySubcommandType.java │ │ │ │ │ ├── PartyXpShareCommand.java │ │ │ │ │ ├── alliance │ │ │ │ │ │ ├── PartyAllianceAcceptCommand.java │ │ │ │ │ │ ├── PartyAllianceCommand.java │ │ │ │ │ │ ├── PartyAllianceDisbandCommand.java │ │ │ │ │ │ └── PartyAllianceInviteCommand.java │ │ │ │ │ └── teleport │ │ │ │ │ │ ├── PtpAcceptAnyCommand.java │ │ │ │ │ │ ├── PtpAcceptCommand.java │ │ │ │ │ │ ├── PtpCommand.java │ │ │ │ │ │ └── PtpToggleCommand.java │ │ │ │ ├── player │ │ │ │ │ ├── InspectCommand.java │ │ │ │ │ ├── McRankCommand.java │ │ │ │ │ ├── McTopCommand.java │ │ │ │ │ ├── MccooldownCommand.java │ │ │ │ │ ├── McstatsCommand.java │ │ │ │ │ └── XPBarCommand.java │ │ │ │ ├── server │ │ │ │ │ └── Mcmmoupgrade.java │ │ │ │ └── skills │ │ │ │ │ ├── AcrobaticsCommand.java │ │ │ │ │ ├── AlchemyCommand.java │ │ │ │ │ ├── AprilCommand.java │ │ │ │ │ ├── ArcheryCommand.java │ │ │ │ │ ├── AxesCommand.java │ │ │ │ │ ├── CrossbowsCommand.java │ │ │ │ │ ├── ExcavationCommand.java │ │ │ │ │ ├── FishingCommand.java │ │ │ │ │ ├── HerbalismCommand.java │ │ │ │ │ ├── MacesCommand.java │ │ │ │ │ ├── MiningCommand.java │ │ │ │ │ ├── MmoInfoCommand.java │ │ │ │ │ ├── PowerLevelCommand.java │ │ │ │ │ ├── RepairCommand.java │ │ │ │ │ ├── SalvageCommand.java │ │ │ │ │ ├── SkillCommand.java │ │ │ │ │ ├── SkillGuideCommand.java │ │ │ │ │ ├── SmeltingCommand.java │ │ │ │ │ ├── SwordsCommand.java │ │ │ │ │ ├── TamingCommand.java │ │ │ │ │ ├── TridentsCommand.java │ │ │ │ │ ├── UnarmedCommand.java │ │ │ │ │ └── WoodcuttingCommand.java │ │ │ │ ├── config │ │ │ │ ├── AdvancedConfig.java │ │ │ │ ├── AutoUpdateLegacyConfigLoader.java │ │ │ │ ├── BukkitConfig.java │ │ │ │ ├── ChatConfig.java │ │ │ │ ├── CoreSkillsConfig.java │ │ │ │ ├── CustomItemSupportConfig.java │ │ │ │ ├── GeneralConfig.java │ │ │ │ ├── HiddenConfig.java │ │ │ │ ├── LegacyConfigLoader.java │ │ │ │ ├── PersistentDataConfig.java │ │ │ │ ├── RankConfig.java │ │ │ │ ├── SoundConfig.java │ │ │ │ ├── WorldBlacklist.java │ │ │ │ ├── experience │ │ │ │ │ └── ExperienceConfig.java │ │ │ │ ├── party │ │ │ │ │ ├── ItemWeightConfig.java │ │ │ │ │ └── PartyConfig.java │ │ │ │ ├── skills │ │ │ │ │ ├── alchemy │ │ │ │ │ │ └── PotionConfig.java │ │ │ │ │ ├── repair │ │ │ │ │ │ ├── RepairConfig.java │ │ │ │ │ │ └── RepairConfigManager.java │ │ │ │ │ └── salvage │ │ │ │ │ │ ├── SalvageConfig.java │ │ │ │ │ │ └── SalvageConfigManager.java │ │ │ │ └── treasure │ │ │ │ │ ├── FishingTreasureConfig.java │ │ │ │ │ └── TreasureConfig.java │ │ │ │ ├── database │ │ │ │ ├── DatabaseManager.java │ │ │ │ ├── DatabaseManagerFactory.java │ │ │ │ ├── ExpectedType.java │ │ │ │ ├── FlatFileDataFlag.java │ │ │ │ ├── FlatFileDataProcessor.java │ │ │ │ ├── FlatFileDatabaseManager.java │ │ │ │ ├── SQLDatabaseManager.java │ │ │ │ ├── UserQuery.java │ │ │ │ ├── UserQueryFull.java │ │ │ │ ├── UserQueryName.java │ │ │ │ ├── UserQueryNameImpl.java │ │ │ │ ├── UserQueryType.java │ │ │ │ ├── UserQueryUUID.java │ │ │ │ ├── UserQueryUUIDImpl.java │ │ │ │ └── flatfile │ │ │ │ │ ├── BadCategorizedFlatFileData.java │ │ │ │ │ ├── CategorizedFlatFileData.java │ │ │ │ │ ├── FlatFileDataBuilder.java │ │ │ │ │ ├── FlatFileDataContainer.java │ │ │ │ │ ├── FlatFileDataUtil.java │ │ │ │ │ └── LeaderboardStatus.java │ │ │ │ ├── datatypes │ │ │ │ ├── BlockLocationHistory.java │ │ │ │ ├── BlockSnapshot.java │ │ │ │ ├── LevelUpBroadcastPredicate.java │ │ │ │ ├── MobHealthbarType.java │ │ │ │ ├── PowerLevelUpBroadcastPredicate.java │ │ │ │ ├── chat │ │ │ │ │ └── ChatChannel.java │ │ │ │ ├── database │ │ │ │ │ ├── DatabaseType.java │ │ │ │ │ ├── PlayerStat.java │ │ │ │ │ └── UpgradeType.java │ │ │ │ ├── experience │ │ │ │ │ ├── FormulaType.java │ │ │ │ │ ├── SkillXpGain.java │ │ │ │ │ ├── XPGainReason.java │ │ │ │ │ └── XPGainSource.java │ │ │ │ ├── interactions │ │ │ │ │ └── NotificationType.java │ │ │ │ ├── json │ │ │ │ │ ├── CustomBaseComponent.java │ │ │ │ │ ├── McMMOUrl.java │ │ │ │ │ └── McMMOWebLinks.java │ │ │ │ ├── meta │ │ │ │ │ ├── BonusDropMeta.java │ │ │ │ │ ├── OldName.java │ │ │ │ │ ├── RecentlyReplantedCropMeta.java │ │ │ │ │ ├── RuptureTaskMeta.java │ │ │ │ │ ├── SuperAbilityToolMeta.java │ │ │ │ │ └── UUIDMeta.java │ │ │ │ ├── mods │ │ │ │ │ ├── CustomBlock.java │ │ │ │ │ ├── CustomEntity.java │ │ │ │ │ └── CustomTool.java │ │ │ │ ├── notifications │ │ │ │ │ └── SensitiveCommandType.java │ │ │ │ ├── party │ │ │ │ │ ├── ItemShareType.java │ │ │ │ │ ├── Party.java │ │ │ │ │ ├── PartyFeature.java │ │ │ │ │ ├── PartyLeader.java │ │ │ │ │ ├── PartyTeleportRecord.java │ │ │ │ │ └── ShareMode.java │ │ │ │ ├── player │ │ │ │ │ ├── McMMOPlayer.java │ │ │ │ │ ├── PlayerProfile.java │ │ │ │ │ └── UniqueDataType.java │ │ │ │ ├── skills │ │ │ │ │ ├── ItemType.java │ │ │ │ │ ├── MaterialType.java │ │ │ │ │ ├── PrimarySkillType.java │ │ │ │ │ ├── SubSkillFlags.java │ │ │ │ │ ├── SubSkillType.java │ │ │ │ │ ├── SuperAbilityType.java │ │ │ │ │ ├── ToolType.java │ │ │ │ │ ├── alchemy │ │ │ │ │ │ ├── AlchemyPotion.java │ │ │ │ │ │ └── PotionStage.java │ │ │ │ │ ├── interfaces │ │ │ │ │ │ ├── ChildSkill.java │ │ │ │ │ │ ├── CoreSkill.java │ │ │ │ │ │ ├── Localized.java │ │ │ │ │ │ ├── Skill.java │ │ │ │ │ │ └── Toolable.java │ │ │ │ │ ├── progression │ │ │ │ │ │ └── Progression.java │ │ │ │ │ └── subskills │ │ │ │ │ │ ├── AbstractSubSkill.java │ │ │ │ │ │ ├── acrobatics │ │ │ │ │ │ ├── AcrobaticsSubSkill.java │ │ │ │ │ │ ├── Roll.java │ │ │ │ │ │ └── RollResult.java │ │ │ │ │ │ ├── interfaces │ │ │ │ │ │ ├── InteractType.java │ │ │ │ │ │ ├── Interaction.java │ │ │ │ │ │ ├── Rank.java │ │ │ │ │ │ ├── SubSkill.java │ │ │ │ │ │ └── SubSkillProperties.java │ │ │ │ │ │ └── taming │ │ │ │ │ │ ├── CallOfTheWildType.java │ │ │ │ │ │ └── TamingSummon.java │ │ │ │ └── treasure │ │ │ │ │ ├── EnchantmentTreasure.java │ │ │ │ │ ├── EnchantmentWrapper.java │ │ │ │ │ ├── ExcavationTreasure.java │ │ │ │ │ ├── FishingTreasure.java │ │ │ │ │ ├── FishingTreasureBook.java │ │ │ │ │ ├── HylianTreasure.java │ │ │ │ │ ├── Rarity.java │ │ │ │ │ ├── ShakeTreasure.java │ │ │ │ │ └── Treasure.java │ │ │ │ ├── events │ │ │ │ ├── McMMOReplaceVanillaTreasureEvent.java │ │ │ │ ├── chat │ │ │ │ │ ├── McMMOAdminChatEvent.java │ │ │ │ │ ├── McMMOChatEvent.java │ │ │ │ │ └── McMMOPartyChatEvent.java │ │ │ │ ├── experience │ │ │ │ │ ├── McMMOPlayerExperienceEvent.java │ │ │ │ │ ├── McMMOPlayerLevelChangeEvent.java │ │ │ │ │ ├── McMMOPlayerLevelDownEvent.java │ │ │ │ │ ├── McMMOPlayerLevelUpEvent.java │ │ │ │ │ ├── McMMOPlayerPreXpGainEvent.java │ │ │ │ │ └── McMMOPlayerXpGainEvent.java │ │ │ │ ├── fake │ │ │ │ │ ├── FakeBlockBreakEvent.java │ │ │ │ │ ├── FakeBlockDamageEvent.java │ │ │ │ │ ├── FakeBrewEvent.java │ │ │ │ │ ├── FakeEntityTameEvent.java │ │ │ │ │ ├── FakeEvent.java │ │ │ │ │ ├── FakePlayerAnimationEvent.java │ │ │ │ │ └── FakePlayerFishEvent.java │ │ │ │ ├── hardcore │ │ │ │ │ ├── McMMOPlayerDeathPenaltyEvent.java │ │ │ │ │ ├── McMMOPlayerPreDeathPenaltyEvent.java │ │ │ │ │ ├── McMMOPlayerStatLossEvent.java │ │ │ │ │ └── McMMOPlayerVampirismEvent.java │ │ │ │ ├── items │ │ │ │ │ └── McMMOItemSpawnEvent.java │ │ │ │ ├── party │ │ │ │ │ ├── McMMOPartyAllianceChangeEvent.java │ │ │ │ │ ├── McMMOPartyChangeEvent.java │ │ │ │ │ ├── McMMOPartyLevelUpEvent.java │ │ │ │ │ ├── McMMOPartyTeleportEvent.java │ │ │ │ │ └── McMMOPartyXpGainEvent.java │ │ │ │ ├── players │ │ │ │ │ └── McMMOPlayerProfileLoadEvent.java │ │ │ │ ├── scoreboard │ │ │ │ │ ├── McMMOScoreboardEvent.java │ │ │ │ │ ├── McMMOScoreboardMakeboardEvent.java │ │ │ │ │ ├── McMMOScoreboardObjectiveEvent.java │ │ │ │ │ ├── McMMOScoreboardRevertEvent.java │ │ │ │ │ ├── ScoreboardEventReason.java │ │ │ │ │ └── ScoreboardObjectiveEventReason.java │ │ │ │ └── skills │ │ │ │ │ ├── McMMOPlayerNotificationEvent.java │ │ │ │ │ ├── McMMOPlayerSkillEvent.java │ │ │ │ │ ├── SkillActivationPerkEvent.java │ │ │ │ │ ├── abilities │ │ │ │ │ ├── McMMOPlayerAbilityActivateEvent.java │ │ │ │ │ ├── McMMOPlayerAbilityDeactivateEvent.java │ │ │ │ │ └── McMMOPlayerAbilityEvent.java │ │ │ │ │ ├── alchemy │ │ │ │ │ ├── McMMOPlayerBrewEvent.java │ │ │ │ │ └── McMMOPlayerCatalysisEvent.java │ │ │ │ │ ├── fishing │ │ │ │ │ ├── McMMOPlayerFishingEvent.java │ │ │ │ │ ├── McMMOPlayerFishingTreasureEvent.java │ │ │ │ │ ├── McMMOPlayerMagicHunterEvent.java │ │ │ │ │ ├── McMMOPlayerMasterAnglerEvent.java │ │ │ │ │ └── McMMOPlayerShakeEvent.java │ │ │ │ │ ├── repair │ │ │ │ │ └── McMMOPlayerRepairCheckEvent.java │ │ │ │ │ ├── rupture │ │ │ │ │ └── McMMOEntityDamageByRuptureEvent.java │ │ │ │ │ ├── salvage │ │ │ │ │ └── McMMOPlayerSalvageCheckEvent.java │ │ │ │ │ ├── secondaryabilities │ │ │ │ │ ├── SubSkillBlockEvent.java │ │ │ │ │ ├── SubSkillEvent.java │ │ │ │ │ └── SubSkillRandomCheckEvent.java │ │ │ │ │ ├── taming │ │ │ │ │ └── McMMOPlayerTameEntityEvent.java │ │ │ │ │ └── unarmed │ │ │ │ │ └── McMMOPlayerDisarmEvent.java │ │ │ │ ├── listeners │ │ │ │ ├── BlockListener.java │ │ │ │ ├── ChunkListener.java │ │ │ │ ├── EntityListener.java │ │ │ │ ├── InteractionManager.java │ │ │ │ ├── InventoryListener.java │ │ │ │ ├── PlayerListener.java │ │ │ │ ├── SelfListener.java │ │ │ │ └── WorldListener.java │ │ │ │ ├── locale │ │ │ │ └── LocaleLoader.java │ │ │ │ ├── mcMMO.java │ │ │ │ ├── metadata │ │ │ │ └── MobMetaFlagType.java │ │ │ │ ├── party │ │ │ │ ├── PartyManager.java │ │ │ │ └── ShareHandler.java │ │ │ │ ├── placeholders │ │ │ │ ├── PapiExpansion.java │ │ │ │ ├── PartyIsLeaderPlaceholder.java │ │ │ │ ├── PartyIsMemberPlaceholder.java │ │ │ │ ├── PartyLeaderPlaceholder.java │ │ │ │ ├── PartyNamePlaceholder.java │ │ │ │ ├── PartySizePlaceholder.java │ │ │ │ ├── Placeholder.java │ │ │ │ ├── PowerLevelCapPlaceholder.java │ │ │ │ ├── PowerLevelPlaceholder.java │ │ │ │ ├── SkillExpNeededPlaceholder.java │ │ │ │ ├── SkillExpPlaceholder.java │ │ │ │ ├── SkillExpRemainingPlaceholder.java │ │ │ │ ├── SkillLevelPlaceholder.java │ │ │ │ ├── SkillRankPlaceholder.java │ │ │ │ ├── SkillXpRatePlaceholder.java │ │ │ │ ├── XpEventActivePlaceholder.java │ │ │ │ └── XpRatePlaceholder.java │ │ │ │ ├── protocollib │ │ │ │ ├── ProtocolHandler.java │ │ │ │ └── ProtocolLibManager.java │ │ │ │ ├── runnables │ │ │ │ ├── CheckDateTask.java │ │ │ │ ├── MobDodgeMetaCleanup.java │ │ │ │ ├── MobHealthDisplayUpdaterTask.java │ │ │ │ ├── SaveTimerTask.java │ │ │ │ ├── StickyPistonTrackerTask.java │ │ │ │ ├── TravelingBlockMetaCleanup.java │ │ │ │ ├── backups │ │ │ │ │ └── CleanBackupsTask.java │ │ │ │ ├── commands │ │ │ │ │ ├── McRankCommandAsyncTask.java │ │ │ │ │ ├── McRankCommandDisplayTask.java │ │ │ │ │ ├── McScoreboardKeepTask.java │ │ │ │ │ ├── McTopCommandAsyncTask.java │ │ │ │ │ ├── MctopCommandDisplayTask.java │ │ │ │ │ └── NotifySquelchReminderTask.java │ │ │ │ ├── database │ │ │ │ │ ├── DatabaseConversionTask.java │ │ │ │ │ ├── FormulaConversionTask.java │ │ │ │ │ ├── UUIDUpdateAsyncTask.java │ │ │ │ │ └── UserPurgeTask.java │ │ │ │ ├── items │ │ │ │ │ ├── ChimaeraWingWarmup.java │ │ │ │ │ └── TeleportationWarmup.java │ │ │ │ ├── party │ │ │ │ │ └── PartyAutoKickTask.java │ │ │ │ ├── player │ │ │ │ │ ├── ClearRegisteredXPGainTask.java │ │ │ │ │ ├── PlayerProfileLoadingTask.java │ │ │ │ │ ├── PlayerProfileSaveTask.java │ │ │ │ │ ├── PlayerUpdateInventoryTask.java │ │ │ │ │ └── PowerLevelUpdatingTask.java │ │ │ │ └── skills │ │ │ │ │ ├── AbilityCooldownTask.java │ │ │ │ │ ├── AbilityDisableTask.java │ │ │ │ │ ├── AlchemyBrewCheckTask.java │ │ │ │ │ ├── AlchemyBrewTask.java │ │ │ │ │ ├── AprilTask.java │ │ │ │ │ ├── AwardCombatXpTask.java │ │ │ │ │ ├── BleedContainer.java │ │ │ │ │ ├── BleedTimerTask.java │ │ │ │ │ ├── DelayedCropReplant.java │ │ │ │ │ ├── DelayedHerbalismXPCheckTask.java │ │ │ │ │ ├── ExperienceBarHideTask.java │ │ │ │ │ ├── HerbalismBlockUpdaterTask.java │ │ │ │ │ ├── MasterAnglerTask.java │ │ │ │ │ ├── RuptureTask.java │ │ │ │ │ ├── SkillUnlockNotificationTask.java │ │ │ │ │ └── ToolLowerTask.java │ │ │ │ ├── skills │ │ │ │ ├── SkillManager.java │ │ │ │ ├── acrobatics │ │ │ │ │ ├── Acrobatics.java │ │ │ │ │ └── AcrobaticsManager.java │ │ │ │ ├── alchemy │ │ │ │ │ ├── Alchemy.java │ │ │ │ │ ├── AlchemyManager.java │ │ │ │ │ └── AlchemyPotionBrewer.java │ │ │ │ ├── archery │ │ │ │ │ ├── Archery.java │ │ │ │ │ ├── ArcheryManager.java │ │ │ │ │ └── TrackedEntity.java │ │ │ │ ├── axes │ │ │ │ │ ├── Axes.java │ │ │ │ │ └── AxesManager.java │ │ │ │ ├── crossbows │ │ │ │ │ ├── Crossbows.java │ │ │ │ │ └── CrossbowsManager.java │ │ │ │ ├── excavation │ │ │ │ │ ├── Excavation.java │ │ │ │ │ └── ExcavationManager.java │ │ │ │ ├── fishing │ │ │ │ │ ├── Fishing.java │ │ │ │ │ └── FishingManager.java │ │ │ │ ├── herbalism │ │ │ │ │ ├── Herbalism.java │ │ │ │ │ └── HerbalismManager.java │ │ │ │ ├── maces │ │ │ │ │ └── MacesManager.java │ │ │ │ ├── mining │ │ │ │ │ ├── BlastMining.java │ │ │ │ │ └── MiningManager.java │ │ │ │ ├── repair │ │ │ │ │ ├── ArcaneForging.java │ │ │ │ │ ├── Repair.java │ │ │ │ │ ├── RepairManager.java │ │ │ │ │ └── repairables │ │ │ │ │ │ ├── Repairable.java │ │ │ │ │ │ ├── RepairableFactory.java │ │ │ │ │ │ ├── RepairableManager.java │ │ │ │ │ │ ├── SimpleRepairable.java │ │ │ │ │ │ └── SimpleRepairableManager.java │ │ │ │ ├── salvage │ │ │ │ │ ├── Salvage.java │ │ │ │ │ ├── SalvageManager.java │ │ │ │ │ └── salvageables │ │ │ │ │ │ ├── Salvageable.java │ │ │ │ │ │ ├── SalvageableFactory.java │ │ │ │ │ │ ├── SalvageableManager.java │ │ │ │ │ │ ├── SimpleSalvageable.java │ │ │ │ │ │ └── SimpleSalvageableManager.java │ │ │ │ ├── smelting │ │ │ │ │ ├── Smelting.java │ │ │ │ │ └── SmeltingManager.java │ │ │ │ ├── swords │ │ │ │ │ ├── Swords.java │ │ │ │ │ └── SwordsManager.java │ │ │ │ ├── taming │ │ │ │ │ ├── Taming.java │ │ │ │ │ ├── TamingManager.java │ │ │ │ │ └── TrackedTamingEntity.java │ │ │ │ ├── tridents │ │ │ │ │ └── TridentsManager.java │ │ │ │ ├── unarmed │ │ │ │ │ ├── Unarmed.java │ │ │ │ │ └── UnarmedManager.java │ │ │ │ └── woodcutting │ │ │ │ │ ├── Woodcutting.java │ │ │ │ │ └── WoodcuttingManager.java │ │ │ │ ├── util │ │ │ │ ├── AttributeMapper.java │ │ │ │ ├── BlockUtils.java │ │ │ │ ├── CancellableRunnable.java │ │ │ │ ├── ChimaeraWing.java │ │ │ │ ├── ContainerMetadataUtils.java │ │ │ │ ├── EnchantmentMapper.java │ │ │ │ ├── EnchantmentUtils.java │ │ │ │ ├── EventUtils.java │ │ │ │ ├── FixSpellingNetheriteUtil.java │ │ │ │ ├── HardcoreManager.java │ │ │ │ ├── HolidayManager.java │ │ │ │ ├── ItemMetadataUtils.java │ │ │ │ ├── ItemUtils.java │ │ │ │ ├── LogFilter.java │ │ │ │ ├── LogUtils.java │ │ │ │ ├── MaterialMapStore.java │ │ │ │ ├── MaterialUtils.java │ │ │ │ ├── MetadataConstants.java │ │ │ │ ├── MetadataService.java │ │ │ │ ├── Misc.java │ │ │ │ ├── MobHealthbarUtils.java │ │ │ │ ├── MobMetadataUtils.java │ │ │ │ ├── ModManager.java │ │ │ │ ├── Motd.java │ │ │ │ ├── Permissions.java │ │ │ │ ├── PotionCompatibilityType.java │ │ │ │ ├── PotionEffectUtil.java │ │ │ │ ├── PotionUtil.java │ │ │ │ ├── TransientEntityTracker.java │ │ │ │ ├── TransientMetadataTools.java │ │ │ │ ├── adapter │ │ │ │ │ └── BiomeAdapter.java │ │ │ │ ├── blockmeta │ │ │ │ │ ├── BitSetChunkStore.java │ │ │ │ │ ├── ChunkManager.java │ │ │ │ │ ├── ChunkManagerFactory.java │ │ │ │ │ ├── ChunkStore.java │ │ │ │ │ ├── HashChunkManager.java │ │ │ │ │ ├── McMMOSimpleRegionFile.java │ │ │ │ │ ├── NullChunkManager.java │ │ │ │ │ └── UserBlockTracker.java │ │ │ │ ├── commands │ │ │ │ │ ├── CommandRegistrationManager.java │ │ │ │ │ └── CommandUtils.java │ │ │ │ ├── compat │ │ │ │ │ ├── CompatibilityLayer.java │ │ │ │ │ ├── CompatibilityManager.java │ │ │ │ │ ├── CompatibilityType.java │ │ │ │ │ └── layers │ │ │ │ │ │ ├── AbstractCompatibilityLayer.java │ │ │ │ │ │ ├── AbstractNMSCompatibilityLayer.java │ │ │ │ │ │ ├── attackcooldown │ │ │ │ │ │ ├── DummyPlayerAttackCooldownToolLayer.java │ │ │ │ │ │ ├── PlayerAttackCooldownMethods.java │ │ │ │ │ │ └── PlayerAttackCooldownToolLayer.java │ │ │ │ │ │ ├── bungee │ │ │ │ │ │ ├── AbstractBungeeSerializerCompatibilityLayer.java │ │ │ │ │ │ ├── BungeeLegacySerializerCompatibilityLayer.java │ │ │ │ │ │ └── BungeeModernSerializerCompatibilityLayer.java │ │ │ │ │ │ └── skills │ │ │ │ │ │ ├── AbstractMasterAnglerCompatibility.java │ │ │ │ │ │ └── MasterAnglerCompatibilityLayer.java │ │ │ │ ├── experience │ │ │ │ │ ├── ExperienceBarManager.java │ │ │ │ │ ├── ExperienceBarWrapper.java │ │ │ │ │ └── FormulaManager.java │ │ │ │ ├── nms │ │ │ │ │ ├── NMSConstants.java │ │ │ │ │ └── NMSVersion.java │ │ │ │ ├── platform │ │ │ │ │ ├── AbstractPlatform.java │ │ │ │ │ ├── BukkitPlatform.java │ │ │ │ │ ├── MajorMinorPatchVersion.java │ │ │ │ │ ├── MinecraftGameVersion.java │ │ │ │ │ ├── Platform.java │ │ │ │ │ ├── PlatformBuilder.java │ │ │ │ │ ├── PlatformManager.java │ │ │ │ │ ├── ServerSoftwareType.java │ │ │ │ │ └── version │ │ │ │ │ │ ├── NumericVersioned.java │ │ │ │ │ │ ├── SimpleNumericVersion.java │ │ │ │ │ │ ├── SimpleVersion.java │ │ │ │ │ │ └── Versioned.java │ │ │ │ ├── player │ │ │ │ │ ├── NotificationManager.java │ │ │ │ │ ├── PlayerLevelUtils.java │ │ │ │ │ └── UserManager.java │ │ │ │ ├── random │ │ │ │ │ ├── InvalidStaticChance.java │ │ │ │ │ ├── Probability.java │ │ │ │ │ ├── ProbabilityImpl.java │ │ │ │ │ ├── ProbabilityUtil.java │ │ │ │ │ └── SkillProbabilityType.java │ │ │ │ ├── scoreboards │ │ │ │ │ ├── ObjectiveType.java │ │ │ │ │ ├── ScoreboardManager.java │ │ │ │ │ └── ScoreboardWrapper.java │ │ │ │ ├── skills │ │ │ │ │ ├── CombatUtils.java │ │ │ │ │ ├── ParticleEffectUtils.java │ │ │ │ │ ├── PerksUtils.java │ │ │ │ │ ├── ProjectileUtils.java │ │ │ │ │ ├── RankUtils.java │ │ │ │ │ ├── SkillActivationType.java │ │ │ │ │ ├── SkillTools.java │ │ │ │ │ └── SkillUtils.java │ │ │ │ ├── sounds │ │ │ │ │ ├── SoundManager.java │ │ │ │ │ └── SoundType.java │ │ │ │ ├── text │ │ │ │ │ ├── ConfigStringUtils.java │ │ │ │ │ ├── McMMOMessageType.java │ │ │ │ │ ├── StringUtils.java │ │ │ │ │ ├── TextComponentFactory.java │ │ │ │ │ └── TextUtils.java │ │ │ │ └── upgrade │ │ │ │ │ └── UpgradeManager.java │ │ │ │ └── worldguard │ │ │ │ ├── WorldGuardFlags.java │ │ │ │ ├── WorldGuardManager.java │ │ │ │ └── WorldGuardUtils.java │ │ └── net │ │ │ └── shatteredlands │ │ │ └── shatt │ │ │ └── backup │ │ │ └── ZipLibrary.java │ └── resources │ │ ├── .jenkins │ │ ├── advanced.yml │ │ ├── chat.yml │ │ ├── config.yml │ │ ├── coreskills.yml │ │ ├── custom_item_support.yml │ │ ├── experience.yml │ │ ├── fishing_treasures.yml │ │ ├── hidden.yml │ │ ├── itemweights.yml │ │ ├── locale │ │ ├── locale_cs_CZ.properties │ │ ├── locale_cy.properties │ │ ├── locale_da.properties │ │ ├── locale_de.properties │ │ ├── locale_en_US.properties │ │ ├── locale_es.properties │ │ ├── locale_fi.properties │ │ ├── locale_fr.properties │ │ ├── locale_hu_HU.properties │ │ ├── locale_it.properties │ │ ├── locale_ja_JP.properties │ │ ├── locale_ko.properties │ │ ├── locale_lt_LT.properties │ │ ├── locale_nl.properties │ │ ├── locale_pl.properties │ │ ├── locale_pt_BR.properties │ │ ├── locale_ru.properties │ │ ├── locale_sv.properties │ │ ├── locale_th_TH.properties │ │ ├── locale_zh_CN.properties │ │ └── locale_zh_TW.properties │ │ ├── mods │ │ ├── armor.default.yml │ │ ├── blocks.default.yml │ │ ├── entities.default.yml │ │ └── tools.default.yml │ │ ├── party.yml │ │ ├── persistent_data.yml │ │ ├── plugin.yml │ │ ├── potions.yml │ │ ├── repair.vanilla.yml │ │ ├── salvage.vanilla.yml │ │ ├── skillranks.yml │ │ ├── sounds.yml │ │ ├── treasures.yml │ │ └── upgrades_overhaul.yml ├── test │ ├── java │ │ └── com │ │ │ └── gmail │ │ │ └── nossr50 │ │ │ ├── MMOTestEnvironment.java │ │ │ ├── config │ │ │ └── skills │ │ │ │ └── alchemy │ │ │ │ └── PotionConfigTest.java │ │ │ ├── database │ │ │ ├── FlatFileDataProcessorTest.java │ │ │ ├── FlatFileDatabaseManagerTest.java │ │ │ ├── SQLDatabaseManagerTest.java │ │ │ └── flatfile │ │ │ │ └── FlatFileDataUtilTest.java │ │ │ ├── datatypes │ │ │ └── BlockLocationHistoryTest.java │ │ │ ├── locale │ │ │ └── LocaleLoaderTest.java │ │ │ ├── party │ │ │ └── PartyManagerTest.java │ │ │ ├── skills │ │ │ ├── acrobatics │ │ │ │ └── AcrobaticsTest.java │ │ │ ├── excavation │ │ │ │ └── ExcavationTest.java │ │ │ ├── tridents │ │ │ │ └── TridentsTest.java │ │ │ └── woodcutting │ │ │ │ └── WoodcuttingTest.java │ │ │ └── util │ │ │ ├── PotionEffectUtilTest.java │ │ │ ├── PotionUtilTest.java │ │ │ ├── blockmeta │ │ │ ├── BitSetChunkStoreTest.java │ │ │ ├── BlockStoreTestUtils.java │ │ │ ├── ChunkStoreTest.java │ │ │ ├── LegacyChunkStore.java │ │ │ ├── UnitTestObjectOutputStream.java │ │ │ └── UserBlockTrackerTest.java │ │ │ ├── platform │ │ │ └── MinecraftGameVersionTest.java │ │ │ ├── random │ │ │ ├── ProbabilityTest.java │ │ │ ├── ProbabilityTestUtils.java │ │ │ └── ProbabilityUtilTest.java │ │ │ └── text │ │ │ ├── StringUtilsTest.java │ │ │ └── TextUtilsTest.java │ └── resources │ │ ├── baddatadb.users │ │ ├── healthydb.users │ │ ├── missinglastlogin.users │ │ └── olderdb.users └── util │ └── java │ └── mcMMO │ └── PotionConfigGenerator.java └── standards.md /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | 3 | *.png binary 4 | *.wav binary 5 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: [nossr50] # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 4 | patreon: nossr50 # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | custom: https://paypal.me/nossr50 # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # bash stuff 2 | *.sh 3 | 4 | # Eclipse stuff 5 | /.classpath 6 | /.project 7 | /.settings 8 | /dependency-reduced-pom.xml 9 | 10 | #vs code 11 | /.vscode 12 | 13 | # Maven Depends 14 | /lib 15 | 16 | # gradle 17 | /.gradle 18 | /mcMMO-core/.gradle 19 | /mcMMO-core/gradle 20 | 21 | # netbeans 22 | /nbproject 23 | 24 | # we use maven! 25 | /build.xml 26 | 27 | # maven 28 | /target 29 | 30 | # vim 31 | .*.sw[a-p] 32 | 33 | # various other potential build files 34 | /build 35 | /bin 36 | /dist 37 | /manifest.mf 38 | 39 | /world 40 | 41 | # Mac filesystem dust 42 | *.DS_Store 43 | 44 | # intellij 45 | *.iml 46 | *.ipr 47 | *.iws 48 | .idea/ 49 | 50 | # Project Stuff 51 | /src/main/resources/mcMMO 52 | 53 | # Other Libraries 54 | *.jar 55 | 56 | # Atlassian Stuff 57 | /atlassian-ide-plugin.xml 58 | /nulllocale_override.properties 59 | -------------------------------------------------------------------------------- /src/main/assembly/package.xml: -------------------------------------------------------------------------------- 1 | 2 | bin 3 | false 4 | 5 | zip 6 | 7 | 8 | 9 | ${project.build.directory}/${artifactId}.jar 10 | / 11 | mcMMO.jar 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/main/java/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Main-Class: com.gmail.nossr50.mcMMO 3 | 4 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/api/FakeBlockBreakEventType.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.api; 2 | 3 | public enum FakeBlockBreakEventType { 4 | FAKE, 5 | TREE_FELLER 6 | } 7 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/api/ItemSpawnReason.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.api; 2 | 3 | public enum ItemSpawnReason { 4 | ARROW_RETRIEVAL_ACTIVATED, //Players sometimes can retrieve arrows instead of losing them when hitting a mob 5 | EXCAVATION_TREASURE, //Any drops when excavation treasures activate fall under this 6 | FISHING_EXTRA_FISH, //A config setting allows more fish to be found when fishing, the extra fish are part of this 7 | FISHING_SHAKE_TREASURE, //When using a fishing rod on a mob and finding a treasure via Shake 8 | HYLIAN_LUCK_TREASURE, //When finding a treasure in grass via hylian luck 9 | BLAST_MINING_DEBRIS_NON_ORES, //The non-ore debris that are dropped from blast mining 10 | BLAST_MINING_ORES, //The ore(s) which may include player placed ores being dropped from blast mining 11 | BLAST_MINING_ORES_BONUS_DROP, //Any bonus ores that drop from a result of a players Mining skills 12 | UNARMED_DISARMED_ITEM, //When you disarm an opponent and they drop their weapon 13 | SALVAGE_ENCHANTMENT_BOOK, //When you salvage an enchanted item and get the enchantment back in book form 14 | SALVAGE_MATERIALS, //When you salvage an item and get materials back 15 | TREE_FELLER_DISPLACED_BLOCK, 16 | BONUS_DROPS, //Can be from Mining, Woodcutting, Herbalism, etc 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/api/TreeFellerBlockBreakEvent.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.api; 2 | 3 | import com.gmail.nossr50.events.fake.FakeBlockBreakEvent; 4 | import org.bukkit.block.Block; 5 | import org.bukkit.entity.Player; 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | public class TreeFellerBlockBreakEvent extends FakeBlockBreakEvent { 9 | public TreeFellerBlockBreakEvent(@NotNull Block theBlock, @NotNull Player player) { 10 | super(theBlock, player); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/api/exceptions/IncompleteNamespacedKeyRegister.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.api.exceptions; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | 5 | public class IncompleteNamespacedKeyRegister extends RuntimeException { 6 | private static final long serialVersionUID = -6905157273569301219L; 7 | 8 | public IncompleteNamespacedKeyRegister(@NotNull String message) { 9 | super(message); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/api/exceptions/InvalidFormulaTypeException.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.api.exceptions; 2 | 3 | public class InvalidFormulaTypeException extends RuntimeException { 4 | private static final long serialVersionUID = 3368670229490121886L; 5 | 6 | public InvalidFormulaTypeException() { 7 | super("That is not a valid FormulaType."); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/api/exceptions/InvalidPlayerException.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.api.exceptions; 2 | 3 | public class InvalidPlayerException extends RuntimeException { 4 | private static final long serialVersionUID = 907213002618581385L; 5 | 6 | public InvalidPlayerException() { 7 | super("That player does not exist in the database."); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/api/exceptions/InvalidSkillException.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.api.exceptions; 2 | 3 | public class InvalidSkillException extends RuntimeException { 4 | private static final long serialVersionUID = 942705284195791157L; 5 | 6 | public InvalidSkillException() { 7 | super("That is not a valid skill."); 8 | } 9 | 10 | public InvalidSkillException(String msg) { 11 | super(msg); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/api/exceptions/InvalidXPGainReasonException.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.api.exceptions; 2 | 3 | public class InvalidXPGainReasonException extends RuntimeException { 4 | private static final long serialVersionUID = 4427052841957931157L; 5 | 6 | public InvalidXPGainReasonException() { 7 | super("That is not a valid XPGainReason."); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/api/exceptions/McMMOPlayerNotFoundException.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.api.exceptions; 2 | 3 | import org.bukkit.entity.Player; 4 | import org.jetbrains.annotations.NotNull; 5 | 6 | public class McMMOPlayerNotFoundException extends RuntimeException { 7 | private static final long serialVersionUID = 761917904993202836L; 8 | 9 | public McMMOPlayerNotFoundException(@NotNull Player player) { 10 | super("McMMOPlayer object was not found for [NOTE: This can mean the profile is not loaded yet! : " + player.getName() + " " + player.getUniqueId()); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/api/exceptions/ValueOutOfBoundsException.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.api.exceptions; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | 5 | public class ValueOutOfBoundsException extends RuntimeException { 6 | public ValueOutOfBoundsException(@NotNull String message) { 7 | super(message); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/chat/SamePartyPredicate.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.chat; 2 | 3 | import com.gmail.nossr50.datatypes.party.Party; 4 | import com.gmail.nossr50.datatypes.player.McMMOPlayer; 5 | import com.gmail.nossr50.util.player.UserManager; 6 | import org.bukkit.command.CommandSender; 7 | import org.bukkit.command.ConsoleCommandSender; 8 | import org.bukkit.entity.Player; 9 | 10 | import java.util.function.Predicate; 11 | 12 | public class SamePartyPredicate implements Predicate { 13 | 14 | final Party party; 15 | 16 | public SamePartyPredicate(Party party) { 17 | this.party = party; 18 | } 19 | 20 | @Override 21 | public boolean test(T t) { 22 | //Include the console in the audience 23 | if (t instanceof ConsoleCommandSender) { 24 | return false; //Party audiences are special, we exclude console from them to avoid double messaging since we send a more verbose version to consoles 25 | } else { 26 | if (t instanceof Player player) { 27 | McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); 28 | if (mcMMOPlayer != null) { 29 | return mcMMOPlayer.getParty() == party; 30 | } 31 | } 32 | } 33 | return false; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/chat/author/Author.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.chat.author; 2 | 3 | import com.gmail.nossr50.datatypes.chat.ChatChannel; 4 | import net.kyori.adventure.identity.Identity; 5 | import org.jetbrains.annotations.NotNull; 6 | 7 | public interface Author extends Identity { 8 | 9 | /** 10 | * The name of this author as used in mcMMO chat 11 | * This is the {@link String} representation of the users current chat username 12 | * This can either be the player's display name or the player's official registered nickname with Mojang it depends on the servers chat settings for mcMMO 13 | * 14 | * @param chatChannel which chat channel this is going to 15 | * @return The name of this author as used in mcMMO chat 16 | */ 17 | @NotNull String getAuthoredName(@NotNull ChatChannel chatChannel); 18 | 19 | /** 20 | * Whether this author is a {@link org.bukkit.command.ConsoleCommandSender} 21 | * 22 | * @return true if this author is the console 23 | */ 24 | boolean isConsole(); 25 | 26 | /** 27 | * Whether this author is a {@link org.bukkit.entity.Player} 28 | * @return true if this author is a player 29 | */ 30 | boolean isPlayer(); 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/chat/author/ConsoleAuthor.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.chat.author; 2 | 3 | import com.gmail.nossr50.datatypes.chat.ChatChannel; 4 | import com.gmail.nossr50.util.text.TextUtils; 5 | import org.checkerframework.checker.nullness.qual.NonNull; 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | import java.util.UUID; 9 | 10 | public class ConsoleAuthor implements Author { 11 | private final UUID uuid; 12 | private final @NotNull String name; 13 | 14 | public ConsoleAuthor(@NotNull String name) { 15 | this.uuid = new UUID(0, 0); 16 | this.name = TextUtils.sanitizeForSerializer(name); 17 | } 18 | 19 | //TODO: Think of a less clunky solution later 20 | @Override 21 | public @NotNull String getAuthoredName(@NotNull ChatChannel chatChannel) { 22 | return name; 23 | } 24 | 25 | @Override 26 | public boolean isConsole() { 27 | return true; 28 | } 29 | 30 | @Override 31 | public boolean isPlayer() { 32 | return false; 33 | } 34 | 35 | @Override 36 | public @NonNull UUID uuid() { 37 | return uuid; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/chat/author/PlayerAuthor.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.chat.author; 2 | 3 | import com.gmail.nossr50.config.ChatConfig; 4 | import com.gmail.nossr50.datatypes.chat.ChatChannel; 5 | import org.bukkit.entity.Player; 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | public class PlayerAuthor extends AbstractPlayerAuthor { 9 | 10 | public PlayerAuthor(@NotNull Player player) { 11 | super(player); 12 | } 13 | 14 | @Override 15 | public @NotNull String getAuthoredName(@NotNull ChatChannel chatChannel) { 16 | return getSanitizedName(chatChannel, ChatConfig.getInstance().useDisplayNames(chatChannel)); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/chat/mailer/AbstractChatMailer.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.chat.mailer; 2 | 3 | import org.bukkit.plugin.Plugin; 4 | import org.jetbrains.annotations.NotNull; 5 | 6 | 7 | public abstract class AbstractChatMailer implements ChatMailer { 8 | protected final @NotNull Plugin pluginRef; 9 | 10 | public AbstractChatMailer(@NotNull Plugin pluginRef) { 11 | this.pluginRef = pluginRef; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/chat/mailer/ChatMailer.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.chat.mailer; 2 | 3 | import com.gmail.nossr50.chat.message.ChatMessage; 4 | import org.jetbrains.annotations.NotNull; 5 | 6 | public interface ChatMailer { 7 | /** 8 | * Send out a chat message 9 | * @param chatMessage the {@link ChatMessage} 10 | */ 11 | void sendMail(@NotNull ChatMessage chatMessage); 12 | } -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/chat/message/AdminChatMessage.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.chat.message; 2 | 3 | import com.gmail.nossr50.chat.author.Author; 4 | import com.gmail.nossr50.datatypes.chat.ChatChannel; 5 | import net.kyori.adventure.audience.Audience; 6 | import net.kyori.adventure.text.TextComponent; 7 | import org.bukkit.plugin.Plugin; 8 | import org.jetbrains.annotations.NotNull; 9 | 10 | public class AdminChatMessage extends AbstractChatMessage { 11 | public AdminChatMessage(@NotNull Plugin pluginRef, @NotNull Author author, @NotNull Audience audience, @NotNull String rawMessage, @NotNull TextComponent componentMessage) { 12 | super(pluginRef, author, audience, rawMessage, componentMessage); 13 | } 14 | 15 | @Override 16 | public void sendMessage() { 17 | audience.sendMessage(author, componentMessage); 18 | } 19 | 20 | @Override 21 | public @NotNull String getAuthorDisplayName() { 22 | return author.getAuthoredName(ChatChannel.ADMIN); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/commands/McabilityCommand.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.commands; 2 | 3 | import com.gmail.nossr50.datatypes.player.McMMOPlayer; 4 | import com.gmail.nossr50.locale.LocaleLoader; 5 | import com.gmail.nossr50.util.Permissions; 6 | import org.bukkit.command.CommandSender; 7 | 8 | public class McabilityCommand extends ToggleCommand { 9 | @Override 10 | protected boolean hasOtherPermission(CommandSender sender) { 11 | return Permissions.mcabilityOthers(sender); 12 | } 13 | 14 | @Override 15 | protected boolean hasSelfPermission(CommandSender sender) { 16 | return Permissions.mcability(sender); 17 | } 18 | 19 | @Override 20 | protected void applyCommandAction(McMMOPlayer mcMMOPlayer) { 21 | mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.Ability." + (mcMMOPlayer.getAbilityUse() ? "Off" : "On"))); 22 | mcMMOPlayer.toggleAbilityUse(); 23 | } 24 | 25 | @Override 26 | protected void sendSuccessMessage(CommandSender sender, String playerName) { 27 | sender.sendMessage(LocaleLoader.getString("Commands.Ability.Toggle", playerName)); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/commands/McgodCommand.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.commands; 2 | 3 | import com.gmail.nossr50.datatypes.player.McMMOPlayer; 4 | import com.gmail.nossr50.locale.LocaleLoader; 5 | import com.gmail.nossr50.util.Permissions; 6 | import org.bukkit.command.CommandSender; 7 | 8 | public class McgodCommand extends ToggleCommand { 9 | @Override 10 | protected boolean hasOtherPermission(CommandSender sender) { 11 | return Permissions.mcgodOthers(sender); 12 | } 13 | 14 | @Override 15 | protected boolean hasSelfPermission(CommandSender sender) { 16 | return Permissions.mcgod(sender); 17 | } 18 | 19 | @Override 20 | protected void applyCommandAction(McMMOPlayer mcMMOPlayer) { 21 | mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.GodMode." + (mcMMOPlayer.getGodMode() ? "Disabled" : "Enabled"))); 22 | mcMMOPlayer.toggleGodMode(); 23 | } 24 | 25 | @Override 26 | protected void sendSuccessMessage(CommandSender sender, String playerName) { 27 | sender.sendMessage(LocaleLoader.getString("Commands.GodMode.Toggle", playerName)); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/commands/McrefreshCommand.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.commands; 2 | 3 | import com.gmail.nossr50.datatypes.player.McMMOPlayer; 4 | import com.gmail.nossr50.locale.LocaleLoader; 5 | import com.gmail.nossr50.util.Permissions; 6 | import org.bukkit.command.CommandSender; 7 | 8 | public class McrefreshCommand extends ToggleCommand { 9 | @Override 10 | protected boolean hasOtherPermission(CommandSender sender) { 11 | return Permissions.mcrefreshOthers(sender); 12 | } 13 | 14 | @Override 15 | protected boolean hasSelfPermission(CommandSender sender) { 16 | return Permissions.mcrefresh(sender); 17 | } 18 | 19 | @Override 20 | protected void applyCommandAction(McMMOPlayer mcMMOPlayer) { 21 | mcMMOPlayer.setRecentlyHurt(0); 22 | mcMMOPlayer.resetCooldowns(); 23 | mcMMOPlayer.resetToolPrepMode(); 24 | mcMMOPlayer.resetAbilityMode(); 25 | 26 | mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Ability.Generic.Refresh")); 27 | } 28 | 29 | @Override 30 | protected void sendSuccessMessage(CommandSender sender, String playerName) { 31 | sender.sendMessage(LocaleLoader.getString("Commands.mcrefresh.Success", playerName)); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/commands/admin/CompatibilityCommand.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.commands.admin; 2 | 3 | import com.gmail.nossr50.mcMMO; 4 | import org.bukkit.command.Command; 5 | import org.bukkit.command.CommandExecutor; 6 | import org.bukkit.command.CommandSender; 7 | import org.jetbrains.annotations.NotNull; 8 | 9 | public class CompatibilityCommand implements CommandExecutor { 10 | 11 | /** 12 | * Executes the given command, returning its success. 13 | *
14 | * If false is returned, then the "usage" plugin.yml entry for this command 15 | * (if defined) will be sent to the player. 16 | * 17 | * @param commandSender Source of the command 18 | * @param command Command which was executed 19 | * @param s Alias of the command which was used 20 | * @param strings Passed command arguments 21 | * @return true if a valid command, otherwise false 22 | */ 23 | @Override 24 | public boolean onCommand(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String s, @NotNull String[] strings) { 25 | mcMMO.getCompatibilityManager().reportCompatibilityStatus(commandSender); 26 | return true; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/commands/admin/McmmoReloadLocaleCommand.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.commands.admin; 2 | 3 | import com.gmail.nossr50.locale.LocaleLoader; 4 | import com.gmail.nossr50.util.Permissions; 5 | import org.bukkit.command.Command; 6 | import org.bukkit.command.CommandExecutor; 7 | import org.bukkit.command.CommandSender; 8 | import org.jetbrains.annotations.NotNull; 9 | 10 | /** 11 | * @author Mark Vainomaa 12 | */ 13 | public final class McmmoReloadLocaleCommand implements CommandExecutor { 14 | @Override 15 | public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { 16 | if (args.length == 0) { 17 | if (!Permissions.reloadlocale(sender)) { 18 | sender.sendMessage(command.getPermissionMessage()); 19 | return true; 20 | } 21 | 22 | LocaleLoader.reloadLocale(); 23 | sender.sendMessage(LocaleLoader.getString("Locale.Reloaded")); 24 | 25 | return true; 26 | } 27 | return false; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/commands/admin/PlayerDebugCommand.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.commands.admin; 2 | 3 | import com.gmail.nossr50.datatypes.player.McMMOPlayer; 4 | import com.gmail.nossr50.util.player.NotificationManager; 5 | import com.gmail.nossr50.util.player.UserManager; 6 | import org.bukkit.command.Command; 7 | import org.bukkit.command.CommandExecutor; 8 | import org.bukkit.command.CommandSender; 9 | import org.bukkit.entity.Player; 10 | import org.jetbrains.annotations.NotNull; 11 | 12 | public class PlayerDebugCommand implements CommandExecutor { 13 | 14 | @Override 15 | public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { 16 | if (sender instanceof Player) { 17 | McMMOPlayer mcMMOPlayer = UserManager.getPlayer((Player) sender); 18 | mcMMOPlayer.toggleDebugMode(); //Toggle debug mode 19 | NotificationManager.sendPlayerInformationChatOnlyPrefixed(mcMMOPlayer.getPlayer(), "Commands.Mmodebug.Toggle", String.valueOf(mcMMOPlayer.isDebugMode())); 20 | return true; 21 | } else { 22 | return false; 23 | } 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/commands/chat/McChatSpy.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.commands.chat; 2 | 3 | import com.gmail.nossr50.commands.ToggleCommand; 4 | import com.gmail.nossr50.datatypes.player.McMMOPlayer; 5 | import com.gmail.nossr50.locale.LocaleLoader; 6 | import com.gmail.nossr50.util.Permissions; 7 | import org.bukkit.command.CommandSender; 8 | 9 | public class McChatSpy extends ToggleCommand { 10 | @Override 11 | protected boolean hasOtherPermission(CommandSender sender) { 12 | return Permissions.adminChatSpyOthers(sender); 13 | } 14 | 15 | @Override 16 | protected boolean hasSelfPermission(CommandSender sender) { 17 | return Permissions.adminChatSpy(sender); 18 | } 19 | 20 | @Override 21 | protected void applyCommandAction(McMMOPlayer mcMMOPlayer) { 22 | mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.AdminChatSpy." + (mcMMOPlayer.isPartyChatSpying() ? "Disabled" : "Enabled"))); 23 | mcMMOPlayer.togglePartyChatSpying(); 24 | } 25 | 26 | @Override 27 | protected void sendSuccessMessage(CommandSender sender, String playerName) { 28 | sender.sendMessage(LocaleLoader.getString("Commands.AdminChatSpy.Toggle", playerName)); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/commands/database/McpurgeCommand.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.commands.database; 2 | 3 | import com.gmail.nossr50.locale.LocaleLoader; 4 | import com.gmail.nossr50.mcMMO; 5 | import com.google.common.collect.ImmutableList; 6 | import org.bukkit.command.Command; 7 | import org.bukkit.command.CommandSender; 8 | import org.bukkit.command.TabExecutor; 9 | import org.jetbrains.annotations.NotNull; 10 | 11 | import java.util.List; 12 | 13 | public class McpurgeCommand implements TabExecutor { 14 | @Override 15 | public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { 16 | if (args.length == 0) { 17 | mcMMO.getDatabaseManager().purgePowerlessUsers(); 18 | 19 | if (mcMMO.p.getGeneralConfig().getOldUsersCutoff() != -1) { 20 | mcMMO.getDatabaseManager().purgeOldUsers(); 21 | } 22 | 23 | sender.sendMessage(LocaleLoader.getString("Commands.mcpurge.Success")); 24 | return true; 25 | } 26 | return false; 27 | } 28 | 29 | @Override 30 | public List onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) { 31 | return ImmutableList.of(); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/commands/database/MmoshowdbCommand.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.commands.database; 2 | 3 | import com.gmail.nossr50.database.DatabaseManagerFactory; 4 | import com.gmail.nossr50.locale.LocaleLoader; 5 | import com.gmail.nossr50.mcMMO; 6 | import com.google.common.collect.ImmutableList; 7 | import org.bukkit.command.Command; 8 | import org.bukkit.command.CommandSender; 9 | import org.bukkit.command.TabExecutor; 10 | import org.jetbrains.annotations.NotNull; 11 | 12 | import java.util.List; 13 | 14 | public class MmoshowdbCommand implements TabExecutor { 15 | @Override 16 | public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { 17 | if (args.length == 0) { 18 | Class clazz = DatabaseManagerFactory.getCustomDatabaseManagerClass(); 19 | 20 | if (clazz != null) { 21 | sender.sendMessage(LocaleLoader.getString("Commands.mmoshowdb", clazz.getName())); 22 | return true; 23 | } 24 | 25 | sender.sendMessage(LocaleLoader.getString("Commands.mmoshowdb", (mcMMO.p.getGeneralConfig().getUseMySQL() ? "sql" : "flatfile"))); 26 | return true; 27 | } 28 | return false; 29 | } 30 | 31 | @Override 32 | public List onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) { 33 | return ImmutableList.of(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/commands/party/PartyHelpCommand.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.commands.party; 2 | 3 | import com.gmail.nossr50.locale.LocaleLoader; 4 | import org.bukkit.command.Command; 5 | import org.bukkit.command.CommandExecutor; 6 | import org.bukkit.command.CommandSender; 7 | import org.jetbrains.annotations.NotNull; 8 | 9 | public class PartyHelpCommand implements CommandExecutor { 10 | 11 | @Override 12 | public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { 13 | if (args.length == 1) { 14 | sender.sendMessage(LocaleLoader.getString("Party.Help.3", "/party join", "/party quit")); 15 | sender.sendMessage(LocaleLoader.getString("Party.Help.1", "/party create")); 16 | sender.sendMessage(LocaleLoader.getString("Party.Help.4", "/party ")); 17 | sender.sendMessage(LocaleLoader.getString("Party.Help.5", "/party password")); 18 | sender.sendMessage(LocaleLoader.getString("Party.Help.6", "/party kick")); 19 | sender.sendMessage(LocaleLoader.getString("Party.Help.7", "/party leader")); 20 | sender.sendMessage(LocaleLoader.getString("Party.Help.8", "/party disband")); 21 | sender.sendMessage(LocaleLoader.getString("Party.Help.9", "/party itemshare")); 22 | sender.sendMessage(LocaleLoader.getString("Party.Help.10", "/party xpshare")); 23 | return true; 24 | } 25 | sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "help")); 26 | return true; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/commands/party/PartySubcommandType.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.commands.party; 2 | 3 | public enum PartySubcommandType { 4 | JOIN, 5 | ACCEPT, 6 | CREATE, 7 | HELP, 8 | INFO, 9 | QUIT, 10 | XPSHARE, 11 | ITEMSHARE, 12 | INVITE, 13 | KICK, 14 | DISBAND, 15 | OWNER, 16 | LOCK, 17 | UNLOCK, 18 | PASSWORD, 19 | RENAME, 20 | TELEPORT, 21 | CHAT, 22 | ALLIANCE; 23 | 24 | public static PartySubcommandType getSubcommand(String commandName) { 25 | for (PartySubcommandType command : values()) { 26 | if (command.name().equalsIgnoreCase(commandName)) { 27 | return command; 28 | } 29 | } 30 | 31 | if (commandName.equalsIgnoreCase("?")) { 32 | return HELP; 33 | } else if (commandName.equalsIgnoreCase("q") || commandName.equalsIgnoreCase("leave")) { 34 | return QUIT; 35 | } else if (commandName.equalsIgnoreCase("leader")) { 36 | return OWNER; 37 | } else if (commandName.equalsIgnoreCase("xpshare") || commandName.equalsIgnoreCase("shareexp") || commandName.equalsIgnoreCase("sharexp")) { 38 | return XPSHARE; 39 | } else if (commandName.equalsIgnoreCase("shareitem") || commandName.equalsIgnoreCase("shareitems")) { 40 | return ITEMSHARE; 41 | } else if (commandName.equalsIgnoreCase("ally")) { 42 | return ALLIANCE; 43 | } 44 | 45 | return null; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/commands/party/teleport/PtpAcceptAnyCommand.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.commands.party.teleport; 2 | 3 | import com.gmail.nossr50.datatypes.party.PartyTeleportRecord; 4 | import com.gmail.nossr50.locale.LocaleLoader; 5 | import com.gmail.nossr50.util.Permissions; 6 | import com.gmail.nossr50.util.player.UserManager; 7 | import org.bukkit.command.Command; 8 | import org.bukkit.command.CommandExecutor; 9 | import org.bukkit.command.CommandSender; 10 | import org.jetbrains.annotations.NotNull; 11 | 12 | public class PtpAcceptAnyCommand implements CommandExecutor { 13 | @Override 14 | public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { 15 | if (!Permissions.partyTeleportAcceptAll(sender)) { 16 | sender.sendMessage(command.getPermissionMessage()); 17 | return true; 18 | } 19 | 20 | PartyTeleportRecord ptpRecord = UserManager.getPlayer(sender.getName()).getPartyTeleportRecord(); 21 | 22 | if (ptpRecord.isConfirmRequired()) { 23 | sender.sendMessage(LocaleLoader.getString("Commands.ptp.AcceptAny.Disabled")); 24 | } else { 25 | sender.sendMessage(LocaleLoader.getString("Commands.ptp.AcceptAny.Enabled")); 26 | } 27 | 28 | ptpRecord.toggleConfirmRequired(); 29 | return true; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/commands/party/teleport/PtpToggleCommand.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.commands.party.teleport; 2 | 3 | import com.gmail.nossr50.datatypes.party.PartyTeleportRecord; 4 | import com.gmail.nossr50.locale.LocaleLoader; 5 | import com.gmail.nossr50.util.Permissions; 6 | import com.gmail.nossr50.util.player.UserManager; 7 | import org.bukkit.command.Command; 8 | import org.bukkit.command.CommandExecutor; 9 | import org.bukkit.command.CommandSender; 10 | import org.jetbrains.annotations.NotNull; 11 | 12 | public class PtpToggleCommand implements CommandExecutor { 13 | @Override 14 | public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { 15 | if (!Permissions.partyTeleportToggle(sender)) { 16 | sender.sendMessage(command.getPermissionMessage()); 17 | return true; 18 | } 19 | 20 | PartyTeleportRecord ptpRecord = UserManager.getPlayer(sender.getName()).getPartyTeleportRecord(); 21 | 22 | if (ptpRecord.isEnabled()) { 23 | sender.sendMessage(LocaleLoader.getString("Commands.ptp.Disabled")); 24 | } else { 25 | sender.sendMessage(LocaleLoader.getString("Commands.ptp.Enabled")); 26 | } 27 | 28 | ptpRecord.toggleEnabled(); 29 | return true; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/commands/server/Mcmmoupgrade.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.commands.server; 2 | 3 | import org.bukkit.command.Command; 4 | import org.bukkit.command.CommandExecutor; 5 | import org.bukkit.command.CommandSender; 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | /** 9 | * This command facilitates switching the skill system scale between classic and modern scale 10 | */ 11 | public class Mcmmoupgrade implements CommandExecutor { 12 | @Override 13 | public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { 14 | return false; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/config/CustomItemSupportConfig.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.config; 2 | 3 | import java.io.File; 4 | 5 | public class CustomItemSupportConfig extends BukkitConfig { 6 | public CustomItemSupportConfig(File dataFolder) { 7 | super("custom_item_support.yml", dataFolder); 8 | validate(); 9 | } 10 | 11 | @Override 12 | protected void loadKeys() { 13 | 14 | } 15 | 16 | public boolean isCustomRepairAllowed() { 17 | return config.getBoolean("Custom_Item_Support.Repair.Allow_Repair_On_Items_With_Custom_Model_Data", true); 18 | } 19 | 20 | public boolean isCustomSalvageAllowed() { 21 | return config.getBoolean("Custom_Item_Support.Salvage.Allow_Salvage_On_Items_With_Custom_Model_Data", true); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/config/HiddenConfig.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.config; 2 | 3 | import com.gmail.nossr50.mcMMO; 4 | import org.bukkit.configuration.file.YamlConfiguration; 5 | 6 | import java.io.InputStreamReader; 7 | 8 | public class HiddenConfig { 9 | private static HiddenConfig instance; 10 | private final String fileName; 11 | private YamlConfiguration config; 12 | private int conversionRate; 13 | private boolean useEnchantmentBuffs; 14 | 15 | public HiddenConfig(String fileName) { 16 | this.fileName = fileName; 17 | load(); 18 | } 19 | 20 | public static HiddenConfig getInstance() { 21 | if (instance == null) { 22 | instance = new HiddenConfig("hidden.yml"); 23 | } 24 | 25 | return instance; 26 | } 27 | 28 | public void load() { 29 | InputStreamReader reader = mcMMO.p.getResourceAsReader(fileName); 30 | if (reader != null) { 31 | config = YamlConfiguration.loadConfiguration(reader); 32 | conversionRate = config.getInt("Options.ConversionRate", 1); 33 | useEnchantmentBuffs = config.getBoolean("Options.EnchantmentBuffs", true); 34 | } 35 | } 36 | 37 | 38 | public int getConversionRate() { 39 | return conversionRate; 40 | } 41 | 42 | public boolean useEnchantmentBuffs() { 43 | return useEnchantmentBuffs; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/config/PersistentDataConfig.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.config; 2 | 3 | import com.gmail.nossr50.metadata.MobMetaFlagType; 4 | 5 | public class PersistentDataConfig extends BukkitConfig { 6 | private static PersistentDataConfig instance; 7 | 8 | private PersistentDataConfig() { 9 | super("persistent_data.yml"); 10 | validate(); 11 | } 12 | 13 | public static PersistentDataConfig getInstance() { 14 | if (instance == null) { 15 | instance = new PersistentDataConfig(); 16 | } 17 | 18 | return instance; 19 | } 20 | 21 | @Override 22 | protected void loadKeys() { 23 | //Sigh this old config system... 24 | } 25 | 26 | @Override 27 | protected boolean validateKeys() { 28 | return true; 29 | } 30 | 31 | //Persistent Data Toggles 32 | public boolean isMobPersistent(MobMetaFlagType mobMetaFlagType) { 33 | String key = "Persistent_Data.Mobs.Flags." + mobMetaFlagType.toString() + ".Saved_To_Disk"; 34 | return config.getBoolean(key, false); 35 | } 36 | 37 | public boolean useBlockTracker() { 38 | return config.getBoolean("mcMMO_Region_System.Enabled", true); 39 | } 40 | 41 | 42 | } -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/config/party/ItemWeightConfig.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.config.party; 2 | 3 | import com.gmail.nossr50.config.BukkitConfig; 4 | import org.bukkit.Material; 5 | 6 | import java.util.HashSet; 7 | import java.util.Locale; 8 | 9 | import static com.gmail.nossr50.util.text.ConfigStringUtils.getMaterialConfigString; 10 | 11 | public class ItemWeightConfig extends BukkitConfig { 12 | private static ItemWeightConfig instance; 13 | 14 | private ItemWeightConfig() { 15 | super("itemweights.yml"); 16 | } 17 | 18 | public static ItemWeightConfig getInstance() { 19 | if (instance == null) { 20 | instance = new ItemWeightConfig(); 21 | } 22 | 23 | return instance; 24 | } 25 | 26 | public int getItemWeight(Material material) { 27 | return config.getInt("Item_Weights." + getMaterialConfigString(material).replace(" ", "_"), config.getInt("Item_Weights.Default")); 28 | } 29 | 30 | public HashSet getMiscItems() { 31 | HashSet miscItems = new HashSet<>(); 32 | 33 | for (String item : config.getStringList("Party_Shareables.Misc_Items")) { 34 | Material material = Material.getMaterial(item.toUpperCase(Locale.ENGLISH)); 35 | 36 | if (material != null) { 37 | miscItems.add(material); 38 | } 39 | } 40 | return miscItems; 41 | } 42 | 43 | @Override 44 | protected void loadKeys() { 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/config/party/PartyConfig.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.config.party; 2 | 3 | import com.gmail.nossr50.config.BukkitConfig; 4 | 5 | import java.io.File; 6 | 7 | public class PartyConfig extends BukkitConfig { 8 | public PartyConfig(File dataFolder) { 9 | super("party.yml", dataFolder); 10 | validate(); 11 | } 12 | 13 | @Override 14 | protected void loadKeys() { 15 | 16 | } 17 | 18 | public boolean isPartyEnabled() { 19 | return config.getBoolean("Party.Enabled", true); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/config/skills/repair/RepairConfigManager.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.config.skills.repair; 2 | 3 | import com.gmail.nossr50.mcMMO; 4 | import com.gmail.nossr50.skills.repair.repairables.Repairable; 5 | 6 | import java.io.File; 7 | import java.util.Collection; 8 | import java.util.HashSet; 9 | import java.util.regex.Pattern; 10 | 11 | public class RepairConfigManager { 12 | public static final String REPAIR_VANILLA_YML = "repair.vanilla.yml"; 13 | private static final Collection repairables = new HashSet<>(); 14 | 15 | public RepairConfigManager(mcMMO plugin) { 16 | Pattern pattern = Pattern.compile("repair\\.(?:.+)\\.yml"); 17 | File dataFolder = plugin.getDataFolder(); 18 | 19 | RepairConfig mainRepairConfig = new RepairConfig(REPAIR_VANILLA_YML, true); 20 | repairables.addAll(mainRepairConfig.getLoadedRepairables()); 21 | 22 | for (String fileName : dataFolder.list()) { 23 | if (fileName.equals(REPAIR_VANILLA_YML)) 24 | continue; 25 | 26 | if (!pattern.matcher(fileName).matches()) { 27 | continue; 28 | } 29 | 30 | File file = new File(dataFolder, fileName); 31 | 32 | if (file.isDirectory()) { 33 | continue; 34 | } 35 | 36 | RepairConfig rConfig = new RepairConfig(fileName, false); 37 | repairables.addAll(rConfig.getLoadedRepairables()); 38 | } 39 | } 40 | 41 | public Collection getLoadedRepairables() { 42 | return repairables; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/database/ExpectedType.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.database; 2 | 3 | public enum ExpectedType { 4 | STRING, 5 | INTEGER, 6 | LONG, 7 | BOOLEAN, 8 | FLOAT, 9 | DOUBLE, 10 | UUID, 11 | IGNORED, 12 | OUT_OF_RANGE 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/database/FlatFileDataFlag.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.database; 2 | 3 | public enum FlatFileDataFlag { 4 | INCOMPLETE, 5 | BAD_VALUES, 6 | LAST_LOGIN_SCHEMA_UPGRADE, 7 | MISSING_NAME, 8 | DUPLICATE_NAME, 9 | DUPLICATE_UUID, 10 | BAD_UUID_DATA, //Can be because it is missing, null, or corrupted or some other reason 11 | TOO_INCOMPLETE, 12 | CORRUPTED_OR_UNRECOGNIZABLE, 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/database/UserQuery.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.database; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | 5 | public interface UserQuery { 6 | @NotNull UserQueryType getType(); 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/database/UserQueryFull.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.database; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | 5 | import java.util.UUID; 6 | 7 | public class UserQueryFull implements UserQueryUUID, UserQueryName { 8 | 9 | private final @NotNull String name; 10 | private final @NotNull UUID uuid; 11 | 12 | public UserQueryFull(@NotNull String name, @NotNull UUID uuid) { 13 | this.name = name; 14 | this.uuid = uuid; 15 | } 16 | 17 | @Override 18 | public @NotNull UserQueryType getType() { 19 | return UserQueryType.UUID_AND_NAME; 20 | } 21 | 22 | @Override 23 | public @NotNull String getName() { 24 | return name; 25 | } 26 | 27 | @Override 28 | public @NotNull UUID getUUID() { 29 | return uuid; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/database/UserQueryName.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.database; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | 5 | public interface UserQueryName extends UserQuery { 6 | @NotNull String getName(); 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/database/UserQueryNameImpl.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.database; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | 5 | public class UserQueryNameImpl implements UserQueryName { 6 | private final @NotNull String name; 7 | 8 | public UserQueryNameImpl(@NotNull String name) { 9 | this.name = name; 10 | } 11 | 12 | @Override 13 | public @NotNull UserQueryType getType() { 14 | return UserQueryType.NAME; 15 | } 16 | 17 | public @NotNull String getName() { 18 | return name; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/database/UserQueryType.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.database; 2 | 3 | public enum UserQueryType { 4 | UUID_AND_NAME, 5 | UUID, 6 | NAME 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/database/UserQueryUUID.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.database; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | 5 | import java.util.UUID; 6 | 7 | public interface UserQueryUUID extends UserQuery { 8 | 9 | @NotNull UUID getUUID(); 10 | 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/database/UserQueryUUIDImpl.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.database; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | 5 | import java.util.UUID; 6 | 7 | public class UserQueryUUIDImpl implements UserQueryUUID { 8 | private final @NotNull UUID uuid; 9 | 10 | public UserQueryUUIDImpl(@NotNull UUID uuid) { 11 | this.uuid = uuid; 12 | } 13 | 14 | @Override 15 | public @NotNull UserQueryType getType() { 16 | return UserQueryType.UUID; 17 | } 18 | 19 | @Override 20 | public @NotNull UUID getUUID() { 21 | return uuid; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/database/flatfile/BadCategorizedFlatFileData.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.database.flatfile; 2 | 3 | import com.gmail.nossr50.database.FlatFileDataFlag; 4 | import com.google.common.base.Objects; 5 | import org.jetbrains.annotations.NotNull; 6 | 7 | import java.util.Arrays; 8 | import java.util.HashSet; 9 | 10 | public class BadCategorizedFlatFileData extends CategorizedFlatFileData { 11 | private final boolean[] badDataIndexes; 12 | 13 | protected BadCategorizedFlatFileData(int uniqueProcessingId, @NotNull HashSet dataFlags, @NotNull String[] splitData, boolean[] badDataIndexes) { 14 | super(uniqueProcessingId, dataFlags, splitData); 15 | this.badDataIndexes = badDataIndexes; 16 | } 17 | 18 | public boolean[] getBadDataIndexes() { 19 | return badDataIndexes; 20 | } 21 | 22 | @Override 23 | public boolean equals(Object o) { 24 | if (this == o) return true; 25 | if (o == null || getClass() != o.getClass()) return false; 26 | if (!super.equals(o)) return false; 27 | BadCategorizedFlatFileData that = (BadCategorizedFlatFileData) o; 28 | return Objects.equal(badDataIndexes, that.badDataIndexes); 29 | } 30 | 31 | @Override 32 | public int hashCode() { 33 | return Objects.hashCode(super.hashCode(), badDataIndexes); 34 | } 35 | 36 | @Override 37 | public String toString() { 38 | return "BadCategorizedFlatFileData{" + 39 | "badDataIndexes=" + Arrays.toString(badDataIndexes) + 40 | '}'; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/database/flatfile/FlatFileDataContainer.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.database.flatfile; 2 | 3 | import com.gmail.nossr50.database.FlatFileDataFlag; 4 | import org.jetbrains.annotations.NotNull; 5 | import org.jetbrains.annotations.Nullable; 6 | 7 | import java.util.Set; 8 | 9 | public interface FlatFileDataContainer { 10 | default @Nullable Set getDataFlags() { 11 | return null; 12 | } 13 | 14 | @NotNull String[] getSplitData(); 15 | 16 | int getUniqueProcessingId(); 17 | 18 | default boolean isHealthyData() { 19 | return getDataFlags() == null || getDataFlags().size() == 0; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/database/flatfile/LeaderboardStatus.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.database.flatfile; 2 | 3 | public enum LeaderboardStatus { 4 | TOO_SOON_TO_UPDATE, 5 | UPDATED, 6 | FAILED 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/datatypes/BlockLocationHistory.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.datatypes; 2 | 3 | import com.google.common.collect.HashMultiset; 4 | import org.bukkit.Location; 5 | 6 | import java.util.LinkedList; 7 | 8 | /** 9 | * This class works with the assumption that you only pass in Block Locations. If locations have differing pitch/yaw, the logic breaks 10 | */ 11 | public class BlockLocationHistory { 12 | private final LinkedList limitedSizeOrderedList = new LinkedList<>(); 13 | private final HashMultiset lookup = HashMultiset.create(); 14 | private final int maxSize; 15 | 16 | public BlockLocationHistory(int maxSize) { 17 | this.maxSize = maxSize; 18 | } 19 | 20 | /** 21 | * Adds a block location to the history. If the history memory would exceed the max size, it will remove the least recently added block location 22 | * 23 | * @param newItem 24 | */ 25 | public void add(Location newItem) { 26 | limitedSizeOrderedList.addFirst(newItem); 27 | lookup.add(newItem); 28 | if (limitedSizeOrderedList.size() > maxSize) 29 | lookup.remove(limitedSizeOrderedList.removeLast()); 30 | } 31 | 32 | /** 33 | * Returns true if the block location is in the recorded history 34 | * 35 | * @param targetLoc the block location to search for 36 | * @return true if the block location is in the recorded history 37 | */ 38 | public boolean contains(Location targetLoc) { 39 | return lookup.contains(targetLoc); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/datatypes/BlockSnapshot.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.datatypes; 2 | 3 | import org.bukkit.Material; 4 | import org.bukkit.block.Block; 5 | 6 | /** 7 | * Contains a snapshot of a block at a specific moment in time 8 | * Used to check before/after type stuff 9 | */ 10 | public class BlockSnapshot { 11 | private final Material oldType; 12 | private final Block blockRef; 13 | 14 | public BlockSnapshot(Material oldType, Block blockRef) { 15 | this.oldType = oldType; 16 | this.blockRef = blockRef; 17 | } 18 | 19 | public Material getOldType() { 20 | return oldType; 21 | } 22 | 23 | public Block getBlockRef() { 24 | return blockRef; 25 | } 26 | 27 | public boolean hasChangedType() { 28 | return oldType != blockRef.getState().getType(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/datatypes/MobHealthbarType.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.datatypes; 2 | 3 | public enum MobHealthbarType { 4 | HEARTS, 5 | BAR, 6 | DISABLED 7 | } -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/datatypes/chat/ChatChannel.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.datatypes.chat; 2 | 3 | import com.gmail.nossr50.locale.LocaleLoader; 4 | import org.jetbrains.annotations.Nullable; 5 | 6 | public enum ChatChannel { 7 | ADMIN(LocaleLoader.getString("Commands.AdminChat.On"), LocaleLoader.getString("Commands.AdminChat.Off")), 8 | PARTY(LocaleLoader.getString("Commands.Party.Chat.On"), LocaleLoader.getString("Commands.Party.Chat.Off")), 9 | PARTY_OFFICER(null, null), 10 | NONE(null, null); 11 | 12 | private final String enabledMessage; 13 | private final String disabledMessage; 14 | 15 | ChatChannel(@Nullable String enabledMessage, @Nullable String disabledMessage) { 16 | this.enabledMessage = enabledMessage; 17 | this.disabledMessage = disabledMessage; 18 | } 19 | 20 | public String getEnabledMessage() { 21 | return enabledMessage; 22 | } 23 | 24 | public String getDisabledMessage() { 25 | return disabledMessage; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/datatypes/database/DatabaseType.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.datatypes.database; 2 | 3 | public enum DatabaseType { 4 | FLATFILE, 5 | SQL, 6 | CUSTOM; 7 | 8 | public static DatabaseType getDatabaseType(String typeName) { 9 | for (DatabaseType type : values()) { 10 | if (type.name().equalsIgnoreCase(typeName)) { 11 | return type; 12 | } 13 | } 14 | 15 | if (typeName.equalsIgnoreCase("file")) { 16 | return FLATFILE; 17 | } else if (typeName.equalsIgnoreCase("mysql")) { 18 | return SQL; 19 | } 20 | 21 | return CUSTOM; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/datatypes/database/PlayerStat.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.datatypes.database; 2 | 3 | public class PlayerStat { 4 | public String name; 5 | public int statVal = 0; 6 | 7 | public PlayerStat(String name, int value) { 8 | this.name = name; 9 | this.statVal = value; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/datatypes/database/UpgradeType.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.datatypes.database; 2 | 3 | public enum UpgradeType { 4 | ADD_FISHING, 5 | ADD_BLAST_MINING_COOLDOWN, 6 | ADD_SQL_INDEXES, 7 | ADD_MOB_HEALTHBARS, 8 | DROP_SQL_PARTY_NAMES, 9 | DROP_SPOUT, 10 | ADD_ALCHEMY, 11 | ADD_UUIDS, 12 | ADD_UUIDS_PARTY, 13 | ADD_SCOREBOARD_TIPS, 14 | DROP_NAME_UNIQUENESS, 15 | ADD_SKILL_TOTAL, 16 | ADD_UNIQUE_PLAYER_DATA, 17 | FIX_SPELLING_NETHERITE_SALVAGE, 18 | FIX_SPELLING_NETHERITE_REPAIR, 19 | FIX_NETHERITE_SALVAGE_QUANTITIES, 20 | SQL_CHARSET_UTF8MB4 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/datatypes/experience/FormulaType.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.datatypes.experience; 2 | 3 | public enum FormulaType { 4 | LINEAR, 5 | EXPONENTIAL, 6 | UNKNOWN; 7 | 8 | public static FormulaType getFormulaType(String string) { 9 | try { 10 | return valueOf(string); 11 | } 12 | catch (IllegalArgumentException ex) { 13 | return UNKNOWN; 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/datatypes/experience/XPGainReason.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.datatypes.experience; 2 | 3 | public enum XPGainReason { 4 | PVP, 5 | PVE, 6 | VAMPIRISM, 7 | SHARED_PVP, 8 | SHARED_PVE, 9 | COMMAND, 10 | UNKNOWN; 11 | 12 | public static XPGainReason getXPGainReason(String reason) { 13 | for (XPGainReason type : values()) { 14 | if (type.name().equalsIgnoreCase(reason)) { 15 | return type; 16 | } 17 | } 18 | 19 | return null; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/datatypes/experience/XPGainSource.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.datatypes.experience; 2 | 3 | public enum XPGainSource { 4 | SELF, 5 | VAMPIRISM, //From Vampirism kills 6 | PASSIVE, //Smelting, Brewing, etc... 7 | PARTY_MEMBERS, //From other members of a party 8 | COMMAND, 9 | CUSTOM, //Outside Sources 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/datatypes/interactions/NotificationType.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.datatypes.interactions; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | 5 | /** 6 | * This class helps define the types of information interactions we will have with players 7 | */ 8 | public enum NotificationType { 9 | XP_GAIN("ExperienceGain"), 10 | HARDCORE_MODE("HardcoreMode"), 11 | NO_PERMISSION("NoPermission"), 12 | SUBSKILL_UNLOCKED("SubSkillUnlocked"), 13 | LEVEL_UP_MESSAGE("LevelUps"), 14 | HOLIDAY("Holiday"), 15 | SUBSKILL_MESSAGE("SubSkillInteraction"), 16 | SUBSKILL_MESSAGE_FAILED("SubSkillFailed"), 17 | TOOL("ToolReady"), 18 | REQUIREMENTS_NOT_MET("RequirementsNotMet"), 19 | ABILITY_OFF("AbilityOff"), 20 | ABILITY_COOLDOWN("AbilityCoolDown"), 21 | ABILITY_REFRESHED("AbilityRefreshed"), 22 | SUPER_ABILITY("SuperAbilityInteraction"), 23 | SUPER_ABILITY_ALERT_OTHERS("SuperAbilityAlertOthers"), 24 | ITEM_MESSAGE("ItemMessage"), 25 | CHAT_ONLY("ChatOnly"), 26 | PARTY_MESSAGE("PartyMessage"); 27 | 28 | private final String niceName; 29 | 30 | NotificationType(@NotNull String niceName) { 31 | this.niceName = niceName; 32 | } 33 | 34 | @Override 35 | public @NotNull String toString() { 36 | return niceName; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/datatypes/json/CustomBaseComponent.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.datatypes.json; 2 | 3 | import net.md_5.bungee.api.chat.BaseComponent; 4 | 5 | public class CustomBaseComponent extends BaseComponent { 6 | @Override 7 | public BaseComponent duplicate() { 8 | return this; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/datatypes/json/McMMOUrl.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.datatypes.json; 2 | 3 | public class McMMOUrl { 4 | public static final String urlWebsite = "https://www.mcmmo.org"; 5 | public static final String urlDiscord = "https://discord.gg/bJ7pFS9"; 6 | public static final String urlPatreon = "https://www.patreon.com/nossr50"; 7 | public static final String urlWiki = "https://wiki.mcmmo.org/"; 8 | public static final String urlSpigot = "https://spigot.mcmmo.org"; 9 | public static final String urlTranslate = "https://translate.mcmmo.org/"; 10 | 11 | public static String getUrl(McMMOWebLinks webLinks) { 12 | switch(webLinks) { 13 | case WIKI: 14 | return urlWiki; 15 | case PATREON: 16 | return urlPatreon; 17 | case SPIGOT: 18 | return urlSpigot; 19 | case DISCORD: 20 | return urlDiscord; 21 | case WEBSITE: 22 | return urlWebsite; 23 | case HELP_TRANSLATE: 24 | return urlTranslate; 25 | default: 26 | return "https://www.mcmmo.org"; 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/datatypes/json/McMMOWebLinks.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.datatypes.json; 2 | 3 | import com.gmail.nossr50.locale.LocaleLoader; 4 | import com.gmail.nossr50.util.text.StringUtils; 5 | 6 | public enum McMMOWebLinks { 7 | WEBSITE, 8 | DISCORD, 9 | PATREON, 10 | SPIGOT, 11 | HELP_TRANSLATE, 12 | WIKI; 13 | 14 | public String getUrl() { 15 | return McMMOUrl.getUrl(this); 16 | } 17 | 18 | public String getNiceTitle() { 19 | return StringUtils.getCapitalized(toString()); 20 | } 21 | 22 | public String getLocaleDescription() { 23 | switch (this) { 24 | case WEBSITE: 25 | return LocaleLoader.getString( "JSON.URL.Website"); 26 | case DISCORD: 27 | return LocaleLoader.getString( "JSON.URL.Discord"); 28 | case PATREON: 29 | return LocaleLoader.getString( "JSON.URL.Patreon"); 30 | case HELP_TRANSLATE: 31 | return LocaleLoader.getString( "JSON.URL.Translation"); 32 | case SPIGOT: 33 | return LocaleLoader.getString("JSON.URL.Spigot"); 34 | case WIKI: 35 | return LocaleLoader.getString("JSON.URL.Wiki"); 36 | default: 37 | return ""; 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/datatypes/meta/BonusDropMeta.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.datatypes.meta; 2 | 3 | import com.gmail.nossr50.mcMMO; 4 | import org.bukkit.metadata.FixedMetadataValue; 5 | 6 | /** 7 | * Stores how many bonus drops a block should give 8 | */ 9 | public class BonusDropMeta extends FixedMetadataValue { 10 | 11 | public BonusDropMeta(int value, mcMMO plugin) { 12 | super(plugin, value); 13 | } 14 | } -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/datatypes/meta/OldName.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.datatypes.meta; 2 | 3 | import com.gmail.nossr50.mcMMO; 4 | import org.bukkit.metadata.FixedMetadataValue; 5 | 6 | /** 7 | * This class is for storing mob names since we switch them to heart values 8 | */ 9 | public class OldName extends FixedMetadataValue { 10 | 11 | public OldName(String oldName, mcMMO plugin) { 12 | super(plugin, oldName); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/datatypes/meta/RecentlyReplantedCropMeta.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.datatypes.meta; 2 | 3 | import org.bukkit.metadata.FixedMetadataValue; 4 | import org.bukkit.plugin.Plugin; 5 | 6 | public class RecentlyReplantedCropMeta extends FixedMetadataValue { 7 | 8 | /** 9 | * Initializes a FixedMetadataValue with an Object 10 | * 11 | * @param owningPlugin the {@link Plugin} that created this metadata value 12 | */ 13 | public RecentlyReplantedCropMeta(Plugin owningPlugin, Boolean recentlyPlanted) { 14 | super(owningPlugin, recentlyPlanted); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/datatypes/meta/RuptureTaskMeta.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.datatypes.meta; 2 | 3 | import com.gmail.nossr50.runnables.skills.RuptureTask; 4 | import org.bukkit.metadata.FixedMetadataValue; 5 | import org.bukkit.plugin.Plugin; 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | public class RuptureTaskMeta extends FixedMetadataValue { 9 | 10 | private final @NotNull RuptureTask ruptureTask; 11 | /** 12 | * Initializes a FixedMetadataValue with an Object 13 | * 14 | * @param owningPlugin the {@link Plugin} that created this metadata value 15 | * @param ruptureTask the value assigned to this metadata value 16 | */ 17 | public RuptureTaskMeta(@NotNull Plugin owningPlugin, @NotNull RuptureTask ruptureTask) { 18 | super(owningPlugin, ruptureTask); 19 | this.ruptureTask = ruptureTask; 20 | } 21 | 22 | public @NotNull RuptureTask getRuptureTimerTask() { 23 | return ruptureTask; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/datatypes/meta/SuperAbilityToolMeta.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.datatypes.meta; 2 | 3 | import com.gmail.nossr50.mcMMO; 4 | import org.bukkit.metadata.FixedMetadataValue; 5 | 6 | /** 7 | * Stores the original dig speed of a tool, also marks the tool as boosted by super abilities 8 | */ 9 | public class SuperAbilityToolMeta extends FixedMetadataValue { 10 | 11 | public SuperAbilityToolMeta(int value, mcMMO plugin) { 12 | super(plugin, value); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/datatypes/meta/UUIDMeta.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.datatypes.meta; 2 | 3 | import org.bukkit.metadata.FixedMetadataValue; 4 | import org.bukkit.plugin.Plugin; 5 | import org.jetbrains.annotations.NotNull; 6 | import org.jetbrains.annotations.Nullable; 7 | 8 | import java.util.UUID; 9 | 10 | public class UUIDMeta extends FixedMetadataValue { 11 | /** 12 | * Initializes a FixedMetadataValue with an Object 13 | * 14 | * @param owningPlugin the {@link Plugin} that created this metadata value 15 | * @param value the value assigned to this metadata value 16 | */ 17 | public UUIDMeta(@NotNull Plugin owningPlugin, @Nullable UUID value) { 18 | super(owningPlugin, value); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/datatypes/mods/CustomBlock.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.datatypes.mods; 2 | 3 | public class CustomBlock { 4 | private final int xpGain; 5 | private final boolean canDoubleDrop; 6 | private final int smeltingXpGain; 7 | 8 | public CustomBlock(int xpGain, boolean canDoubleDrop, int smeltingXpGain) { 9 | this.xpGain = xpGain; 10 | this.canDoubleDrop = canDoubleDrop; 11 | this.smeltingXpGain = smeltingXpGain; 12 | } 13 | 14 | public int getXpGain() { 15 | return xpGain; 16 | } 17 | 18 | public boolean isDoubleDropEnabled() { 19 | return canDoubleDrop; 20 | } 21 | 22 | public int getSmeltingXpGain() { 23 | return smeltingXpGain; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/datatypes/mods/CustomEntity.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.datatypes.mods; 2 | 3 | import org.bukkit.inventory.ItemStack; 4 | 5 | public class CustomEntity { 6 | private final double xpMultiplier; 7 | private final boolean canBeTamed; 8 | private final int tamingXP; 9 | private final boolean canBeSummoned; 10 | private final ItemStack callOfTheWildItem; 11 | private final int callOfTheWildAmount; 12 | 13 | public CustomEntity(double xpMultiplier, boolean canBeTamed, int tamingXP, boolean canBeSummoned, ItemStack callOfTheWildItem, int callOfTheWildAmount) { 14 | this.xpMultiplier = xpMultiplier; 15 | this.canBeTamed = canBeTamed; 16 | this.tamingXP = tamingXP; 17 | this.canBeSummoned = canBeSummoned; 18 | this.callOfTheWildItem = callOfTheWildItem; 19 | this.callOfTheWildAmount = callOfTheWildAmount; 20 | } 21 | 22 | public double getXpMultiplier() { 23 | return xpMultiplier; 24 | } 25 | 26 | public boolean canBeTamed() { 27 | return canBeTamed; 28 | } 29 | 30 | public int getTamingXP() { 31 | return tamingXP; 32 | } 33 | 34 | public boolean canBeSummoned() { 35 | return canBeSummoned; 36 | } 37 | 38 | public ItemStack getCallOfTheWildItem() { 39 | return callOfTheWildItem; 40 | } 41 | 42 | public int getCallOfTheWildAmount() { 43 | return callOfTheWildAmount; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/datatypes/mods/CustomTool.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.datatypes.mods; 2 | 3 | public class CustomTool { 4 | private final double xpMultiplier; 5 | private final boolean abilityEnabled; 6 | private final int tier; 7 | 8 | public CustomTool(int tier, boolean abilityEnabled, double xpMultiplier) { 9 | this.xpMultiplier = xpMultiplier; 10 | this.abilityEnabled = abilityEnabled; 11 | this.tier = tier; 12 | } 13 | 14 | public double getXpMultiplier() { 15 | return xpMultiplier; 16 | } 17 | 18 | public boolean isAbilityEnabled() { 19 | return abilityEnabled; 20 | } 21 | 22 | public int getTier() { 23 | return tier; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/datatypes/notifications/SensitiveCommandType.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.datatypes.notifications; 2 | 3 | public enum SensitiveCommandType { 4 | XPRATE_MODIFY, 5 | XPRATE_END, 6 | MMOEDIT 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/datatypes/party/ItemShareType.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.datatypes.party; 2 | 3 | import com.gmail.nossr50.locale.LocaleLoader; 4 | import com.gmail.nossr50.util.ItemUtils; 5 | import com.gmail.nossr50.util.text.StringUtils; 6 | import org.bukkit.inventory.ItemStack; 7 | 8 | public enum ItemShareType { 9 | LOOT, 10 | MINING, 11 | HERBALISM, 12 | WOODCUTTING, 13 | MISC; 14 | 15 | public static ItemShareType getShareType(ItemStack itemStack) { 16 | if (ItemUtils.isMobDrop(itemStack)) { 17 | return LOOT; 18 | } else if (ItemUtils.isMiningDrop(itemStack)) { 19 | return MINING; 20 | } else if (ItemUtils.isHerbalismDrop(itemStack)) { 21 | return HERBALISM; 22 | } else if (ItemUtils.isWoodcuttingDrop(itemStack)) { 23 | return WOODCUTTING; 24 | } else if (ItemUtils.isMiscDrop(itemStack)) { 25 | return MISC; 26 | } 27 | 28 | return null; 29 | } 30 | 31 | public String getLocaleString() { 32 | return LocaleLoader.getString("Party.ItemShare.Category." + StringUtils.getCapitalized(this.toString())); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/datatypes/party/PartyLeader.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.datatypes.party; 2 | 3 | import java.util.UUID; 4 | 5 | public class PartyLeader { 6 | private final UUID uuid; 7 | private final String playerName; 8 | 9 | public PartyLeader(UUID uuid, String playerName) { 10 | this.uuid = uuid; 11 | this.playerName = playerName; 12 | } 13 | 14 | public UUID getUniqueId() { 15 | return uuid; 16 | } 17 | 18 | public String getPlayerName() { 19 | return playerName; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/datatypes/party/ShareMode.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.datatypes.party; 2 | 3 | import com.gmail.nossr50.util.commands.CommandUtils; 4 | 5 | public enum ShareMode { 6 | NONE, 7 | EQUAL, 8 | RANDOM; 9 | 10 | public static ShareMode getShareMode(String string) { 11 | try { 12 | return valueOf(string); 13 | } 14 | catch (IllegalArgumentException ex) { 15 | if (string.equalsIgnoreCase("even")) { 16 | return EQUAL; 17 | } else if (CommandUtils.shouldDisableToggle(string)) { 18 | return NONE; 19 | } 20 | 21 | return null; 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/datatypes/player/UniqueDataType.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.datatypes.player; 2 | 3 | public enum UniqueDataType { 4 | CHIMAERA_WING_DATS 5 | } 6 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/datatypes/skills/ItemType.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.datatypes.skills; 2 | 3 | public enum ItemType { 4 | ARMOR, 5 | TOOL, 6 | OTHER 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/datatypes/skills/MaterialType.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.datatypes.skills; 2 | 3 | import org.bukkit.Material; 4 | 5 | public enum MaterialType { 6 | STRING, 7 | LEATHER, 8 | WOOD, 9 | STONE, 10 | IRON, 11 | GOLD, 12 | DIAMOND, 13 | NETHERITE, 14 | PRISMARINE, 15 | OTHER; 16 | 17 | public Material getDefaultMaterial() { 18 | switch (this) { 19 | case STRING: 20 | return Material.STRING; 21 | 22 | case LEATHER: 23 | return Material.LEATHER; 24 | 25 | case WOOD: 26 | return Material.OAK_PLANKS; 27 | 28 | case STONE: 29 | return Material.COBBLESTONE; 30 | 31 | case IRON: 32 | return Material.IRON_INGOT; 33 | 34 | case GOLD: 35 | return Material.GOLD_INGOT; 36 | 37 | case DIAMOND: 38 | return Material.DIAMOND; 39 | 40 | case NETHERITE: 41 | if (Material.getMaterial("NETHERITE_SCRAP") != null) 42 | return Material.getMaterial("NETHERITE_SCRAP"); 43 | else 44 | return Material.DIAMOND; 45 | case PRISMARINE: 46 | return Material.PRISMARINE_CRYSTALS; 47 | 48 | case OTHER: 49 | default: 50 | return null; 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/datatypes/skills/SubSkillFlags.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.datatypes.skills; 2 | 3 | public class SubSkillFlags { 4 | /* 5 | * Bitwise Flags 6 | * These are so I can flag properties for subskills 7 | * Flags are in the power of 2 because binary is a base-2 system 8 | */ 9 | public static final int ACTIVE = 1; //Active subskills are ones that aren't passive 10 | public static final int SUPERABILITY = 2; // Super abilities are redundantly active 11 | public static final int RNG = 4; //If the subskill makes use of RNG 12 | public static final int PVP = 8; //If the subskill has properties that change in PVP conditions 13 | public static final int TIMED = 16; //If the subskill has a duration or time component 14 | public static final int TARGET_COLLECTION = 32; //If the subskill has multiple target types 15 | public static final int REWARD_COLLECTION = 64; //If the subskill has multiple reward types 16 | public static final int CHARGES = 128; 17 | public static final int LIMITED = 256; 18 | //public static final int RANDOM_ACTIVATION = 128; //If the subskill has random activation 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/datatypes/skills/interfaces/ChildSkill.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.datatypes.skills.interfaces; 2 | 3 | import com.gmail.nossr50.datatypes.skills.PrimarySkillType; 4 | 5 | public interface ChildSkill extends Skill { 6 | /** 7 | * Get's the other parent for this Skill 8 | * @return the other parent 9 | */ 10 | PrimarySkillType getSecondParent(); 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/datatypes/skills/interfaces/CoreSkill.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.datatypes.skills.interfaces; 2 | 3 | import com.gmail.nossr50.datatypes.skills.SubSkillType; 4 | 5 | /** 6 | * This interface is mostly here to maintain backwards compatibility with other mcMMO plugins 7 | * Only Core Skills will make use of this 8 | * Previously in mcMMO subskills were basically defined by the SecondaryAbility ENUM 9 | * In the new system which I'm gradually converting all the existing skills to, skills instead are unique instances of AbstractSubSkill 10 | */ 11 | public interface CoreSkill { 12 | /** 13 | * Gets the associated SubSkillType for this subskill 14 | * @return the associated SubSkillType ENUM definition 15 | */ 16 | SubSkillType getSubSkillType(); 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/datatypes/skills/interfaces/Localized.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.datatypes.skills.interfaces; 2 | 3 | /** 4 | * Localized interface represents skills which have localizations 5 | * Skills with localizations will use their localization names/descriptions when being printed 6 | */ 7 | public interface Localized { 8 | /** 9 | * The translated name for this locale 10 | * @return the translated name for this locale 11 | */ 12 | String getLocaleName(); 13 | 14 | /** 15 | * The translated name for this subskill description 16 | * @return 17 | */ 18 | String getLocaleDescription(); 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/datatypes/skills/interfaces/Skill.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.datatypes.skills.interfaces; 2 | 3 | import com.gmail.nossr50.datatypes.skills.PrimarySkillType; 4 | 5 | public interface Skill { 6 | /** 7 | * The primary skill 8 | * @return this primary skill 9 | */ 10 | PrimarySkillType getPrimarySkill(); 11 | 12 | /** 13 | * Returns the key name used for this skill in conjunction with config files 14 | * @return config file key name 15 | */ 16 | String getPrimaryKeyName(); 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/datatypes/skills/interfaces/Toolable.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.datatypes.skills.interfaces; 2 | 3 | import org.bukkit.inventory.ItemStack; 4 | 5 | import java.util.Collection; 6 | 7 | public interface Toolable { 8 | /** 9 | * Whether this Skill requires a tool 10 | * Not all skills will require a tool 11 | * @return true if tool is required 12 | */ 13 | boolean requiresTool(); 14 | 15 | /** 16 | * The tools associated with this Skill 17 | * @return the tools 18 | */ 19 | Collection getTools(); 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/datatypes/skills/progression/Progression.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.datatypes.skills.progression; 2 | 3 | import com.gmail.nossr50.datatypes.skills.subskills.interfaces.InteractType; 4 | import org.bukkit.event.Event; 5 | 6 | public interface Progression { 7 | /** 8 | * The interaction vector for gaining XP 9 | * @return the interaction vector for gaining XP 10 | */ 11 | InteractType getXpGainInteractType(); 12 | 13 | /** 14 | * Executes the interaction for gaining XP 15 | */ 16 | void doXpGainInteraction(Event event); 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/datatypes/skills/subskills/interfaces/InteractType.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.datatypes.skills.subskills.interfaces; 2 | 3 | /** 4 | * This class is used to determine event registrations for SubSkill interactions 5 | */ 6 | public enum InteractType { 7 | ON_BLOCK_BREAK, 8 | ON_BLOCK_DAMAGE, 9 | ON_PROJECTILE_LAUNCH, 10 | ON_BLOCK_PLACE, 11 | ON_ENTITY_DAMAGE, 12 | ON_ENTITY_DAMAGE_BY_ENTITY, 13 | ON_EXPLOSION_PRIME, 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/datatypes/skills/subskills/interfaces/Interaction.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.datatypes.skills.subskills.interfaces; 2 | 3 | import com.gmail.nossr50.mcMMO; 4 | import org.bukkit.event.Event; 5 | import org.bukkit.event.EventPriority; 6 | 7 | public interface Interaction { 8 | /** 9 | * The type of interaction this subskill has with Minecraft 10 | * @return the interaction type 11 | */ 12 | InteractType getInteractType(); 13 | 14 | /** 15 | * Executes the interaction between this subskill and Minecraft 16 | * @param event the vector of interaction 17 | * @param plugin the mcMMO plugin instance 18 | * @return true if interaction wasn't cancelled 19 | */ 20 | boolean doInteraction(Event event, mcMMO plugin); 21 | 22 | /** 23 | * The priority for this interaction 24 | * @return the priority for interaction 25 | */ 26 | EventPriority getEventPriority(); 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/datatypes/skills/subskills/interfaces/Rank.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.datatypes.skills.subskills.interfaces; 2 | 3 | public interface Rank { 4 | /** 5 | * Gets the number of ranks for this subskill, 0 for no ranks 6 | * @return the number of ranks for this subskill, 0 for no ranks 7 | */ 8 | int getNumRanks(); 9 | 10 | /** 11 | * Not all skills have ranks 12 | * @return true if the skill has ranks 13 | */ 14 | boolean hasRanks(); 15 | 16 | /* 17 | An sequential collection of rank level requirements 18 | @return level requirements 19 | */ 20 | //Collection getUnlockLevels(); 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/datatypes/skills/subskills/interfaces/SubSkillProperties.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.datatypes.skills.subskills.interfaces; 2 | 3 | public interface SubSkillProperties { 4 | boolean isSuperAbility(); 5 | 6 | boolean isActiveUse(); 7 | 8 | boolean isPassive(); 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/datatypes/skills/subskills/taming/CallOfTheWildType.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.datatypes.skills.subskills.taming; 2 | 3 | import com.gmail.nossr50.util.text.StringUtils; 4 | import org.bukkit.entity.EntityType; 5 | 6 | public enum CallOfTheWildType { 7 | WOLF, 8 | CAT, 9 | HORSE; 10 | 11 | //TODO: This is a hacky fix to make the COTW code in 2.1 more bearable, this will be removed upon the rework planned for COTW 12 | public String getConfigEntityTypeEntry() { 13 | 14 | switch(this) { 15 | case CAT: 16 | return StringUtils.getPrettyEntityTypeString(EntityType.OCELOT); //Even though cats will be summoned in 1.14, we specify Ocelot here. This will be gone in 2.2 17 | case WOLF: 18 | return StringUtils.getPrettyEntityTypeString(EntityType.WOLF); 19 | case HORSE: 20 | return StringUtils.getPrettyEntityTypeString(EntityType.HORSE); 21 | } 22 | 23 | return null; 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/datatypes/treasure/EnchantmentTreasure.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.datatypes.treasure; 2 | 3 | import org.bukkit.enchantments.Enchantment; 4 | 5 | public class EnchantmentTreasure { 6 | private Enchantment enchantment; 7 | private int level; 8 | 9 | public EnchantmentTreasure(Enchantment enchantment, int level) { 10 | this.setEnchantment(enchantment); 11 | this.setLevel(level); 12 | } 13 | 14 | public Enchantment getEnchantment() { 15 | return enchantment; 16 | } 17 | 18 | public void setEnchantment(Enchantment enchantment) { 19 | this.enchantment = enchantment; 20 | } 21 | 22 | public int getLevel() { 23 | return level; 24 | } 25 | 26 | public void setLevel(int level) { 27 | this.level = level; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/datatypes/treasure/EnchantmentWrapper.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.datatypes.treasure; 2 | 3 | import com.google.common.base.Objects; 4 | import org.bukkit.enchantments.Enchantment; 5 | import org.jetbrains.annotations.NotNull; 6 | 7 | public class EnchantmentWrapper { 8 | private final @NotNull Enchantment enchantment; 9 | private final int enchantmentLevel; 10 | 11 | public EnchantmentWrapper(@NotNull Enchantment enchantment, int enchantmentLevel) { 12 | this.enchantment = enchantment; 13 | this.enchantmentLevel = enchantmentLevel; 14 | } 15 | 16 | public @NotNull Enchantment getEnchantment() { 17 | return enchantment; 18 | } 19 | 20 | public int getEnchantmentLevel() { 21 | return enchantmentLevel; 22 | } 23 | 24 | @Override 25 | public String toString() { 26 | return "EnchantmentWrapper{" + 27 | "enchantment=" + enchantment + 28 | ", enchantmentLevel=" + enchantmentLevel + 29 | '}'; 30 | } 31 | 32 | @Override 33 | public boolean equals(Object o) { 34 | if (this == o) return true; 35 | if (o == null || getClass() != o.getClass()) return false; 36 | EnchantmentWrapper that = (EnchantmentWrapper) o; 37 | return enchantmentLevel == that.enchantmentLevel && Objects.equal(enchantment, that.enchantment); 38 | } 39 | 40 | @Override 41 | public int hashCode() { 42 | return Objects.hashCode(enchantment, enchantmentLevel); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/datatypes/treasure/ExcavationTreasure.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.datatypes.treasure; 2 | 3 | import org.bukkit.inventory.ItemStack; 4 | 5 | public class ExcavationTreasure extends Treasure { 6 | public ExcavationTreasure(ItemStack drop, int xp, double dropChance, int dropLevel) { 7 | super(drop, xp, dropChance, dropLevel); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/datatypes/treasure/FishingTreasure.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.datatypes.treasure; 2 | 3 | import org.bukkit.inventory.ItemStack; 4 | 5 | public class FishingTreasure extends Treasure { 6 | 7 | public FishingTreasure(ItemStack drop, int xp) { 8 | super(drop, xp, 0, 0); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/datatypes/treasure/HylianTreasure.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.datatypes.treasure; 2 | 3 | import org.bukkit.inventory.ItemStack; 4 | 5 | public class HylianTreasure extends Treasure { 6 | public HylianTreasure(ItemStack drop, int xp, double dropChance, int dropLevel) { 7 | super(drop, xp, dropChance, dropLevel); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/datatypes/treasure/Rarity.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.datatypes.treasure; 2 | 3 | import com.gmail.nossr50.mcMMO; 4 | import org.jetbrains.annotations.NotNull; 5 | 6 | public enum Rarity { 7 | MYTHIC, 8 | LEGENDARY, 9 | EPIC, 10 | RARE, 11 | UNCOMMON, 12 | COMMON; 13 | 14 | public static @NotNull Rarity getRarity(@NotNull String string) { 15 | if (string.equalsIgnoreCase("Records")) { 16 | mcMMO.p.getLogger().severe("Entries in fishing treasures have Records set as rarity, however Records was renamed to Mythic. Please update your treasures to read MYTHIC instead of RECORDS for rarity, or delete the config file to regenerate a new one."); 17 | return Rarity.MYTHIC; //People that copy paste their configs will have Records interpretted as Mythic 18 | } 19 | try { 20 | return valueOf(string); 21 | } 22 | catch (IllegalArgumentException ex) { 23 | return COMMON; 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/datatypes/treasure/ShakeTreasure.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.datatypes.treasure; 2 | 3 | import org.bukkit.inventory.ItemStack; 4 | 5 | public class ShakeTreasure extends Treasure { 6 | public ShakeTreasure(ItemStack drop, int xp, double dropChance, int dropLevel) { 7 | super(drop, xp, dropChance, dropLevel); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/events/chat/McMMOAdminChatEvent.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.events.chat; 2 | 3 | import com.gmail.nossr50.chat.message.AbstractChatMessage; 4 | import org.bukkit.plugin.Plugin; 5 | import org.jetbrains.annotations.NotNull; 6 | 7 | /** 8 | * Called when a chat is sent to the admin chat channel 9 | */ 10 | public class McMMOAdminChatEvent extends McMMOChatEvent { 11 | public McMMOAdminChatEvent(@NotNull Plugin plugin, @NotNull AbstractChatMessage chatMessage, boolean isAsync) { 12 | super(plugin, chatMessage, isAsync); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/events/chat/McMMOPartyChatEvent.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.events.chat; 2 | 3 | import com.gmail.nossr50.chat.message.PartyChatMessage; 4 | import com.gmail.nossr50.datatypes.party.Party; 5 | import org.bukkit.plugin.Plugin; 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | /** 9 | * Called when a chat is sent to a party channel 10 | */ 11 | public class McMMOPartyChatEvent extends McMMOChatEvent { 12 | private final @NotNull String party; //Not going to break the API to rename this for now 13 | private final @NotNull Party targetParty; 14 | 15 | public McMMOPartyChatEvent(@NotNull Plugin pluginRef, @NotNull PartyChatMessage chatMessage, @NotNull Party party, boolean isAsync) { 16 | super(pluginRef, chatMessage, isAsync); 17 | this.party = party.getName(); 18 | this.targetParty = party; 19 | } 20 | 21 | /** 22 | * @return String name of the party the message will be sent to 23 | * 24 | * @deprecated this will be removed in the future 25 | */ 26 | @Deprecated 27 | public @NotNull String getParty() { 28 | return party; 29 | } 30 | 31 | public @NotNull PartyChatMessage getPartyChatMessage() { 32 | return (PartyChatMessage) chatMessage; 33 | } 34 | 35 | /** 36 | * The authors party 37 | * 38 | * @return the party that this message will be delivered to 39 | */ 40 | public @NotNull Party getAuthorParty() { 41 | return targetParty; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/events/experience/McMMOPlayerLevelChangeEvent.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.events.experience; 2 | 3 | import com.gmail.nossr50.datatypes.experience.XPGainReason; 4 | import com.gmail.nossr50.datatypes.skills.PrimarySkillType; 5 | import org.bukkit.entity.Player; 6 | 7 | /** 8 | * Called when a user levels change 9 | */ 10 | public abstract class McMMOPlayerLevelChangeEvent extends McMMOPlayerExperienceEvent { 11 | @Deprecated 12 | public McMMOPlayerLevelChangeEvent(Player player, PrimarySkillType skill) { 13 | super(player, skill, XPGainReason.UNKNOWN); 14 | } 15 | 16 | public McMMOPlayerLevelChangeEvent(Player player, PrimarySkillType skill, XPGainReason xpGainReason) { 17 | super(player, skill, xpGainReason); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/events/fake/FakeBlockBreakEvent.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.events.fake; 2 | 3 | import org.bukkit.block.Block; 4 | import org.bukkit.entity.Player; 5 | import org.bukkit.event.block.BlockBreakEvent; 6 | 7 | /** 8 | * Called when mcMMO breaks a block due to a special ability. 9 | */ 10 | public class FakeBlockBreakEvent extends BlockBreakEvent implements FakeEvent { 11 | public FakeBlockBreakEvent(Block theBlock, Player player) { 12 | super(theBlock, player); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/events/fake/FakeBlockDamageEvent.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.events.fake; 2 | 3 | import org.bukkit.block.Block; 4 | import org.bukkit.entity.Player; 5 | import org.bukkit.event.block.BlockDamageEvent; 6 | import org.bukkit.inventory.ItemStack; 7 | 8 | /** 9 | * Called when mcMMO damages a block due to a special ability. 10 | */ 11 | public class FakeBlockDamageEvent extends BlockDamageEvent implements FakeEvent { 12 | public FakeBlockDamageEvent(Player player, Block block, ItemStack itemInHand, boolean instaBreak) { 13 | super(player, block, itemInHand, instaBreak); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/events/fake/FakeBrewEvent.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.events.fake; 2 | 3 | import org.bukkit.block.Block; 4 | import org.bukkit.event.inventory.BrewEvent; 5 | import org.bukkit.inventory.BrewerInventory; 6 | import org.bukkit.inventory.ItemStack; 7 | 8 | import java.util.List; 9 | 10 | public class FakeBrewEvent extends BrewEvent implements FakeEvent { 11 | public FakeBrewEvent(Block brewer, BrewerInventory contents, List results, int fuelLevel) { 12 | super(brewer, contents, results, fuelLevel); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/events/fake/FakeEntityTameEvent.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.events.fake; 2 | 3 | import org.bukkit.entity.AnimalTamer; 4 | import org.bukkit.entity.LivingEntity; 5 | import org.bukkit.event.entity.EntityTameEvent; 6 | 7 | /** 8 | * Called when mcMMO tames an animal via Call of the Wild 9 | */ 10 | public class FakeEntityTameEvent extends EntityTameEvent implements FakeEvent { 11 | public FakeEntityTameEvent(LivingEntity entity, AnimalTamer owner) { 12 | super(entity, owner); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/events/fake/FakeEvent.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.events.fake; 2 | 3 | import org.bukkit.event.Event; 4 | 5 | /** 6 | * This interface marks an {@link Event} as "fake". 7 | * This is just a handy way of checking if an {@link Event} is fake or not, maybe there 8 | * will be methods suitable for this in the future. 9 | * 10 | */ 11 | public interface FakeEvent {} 12 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/events/fake/FakePlayerAnimationEvent.java: -------------------------------------------------------------------------------- 1 | //package com.gmail.nossr50.events.fake; 2 | // 3 | //import org.bukkit.entity.Player; 4 | //import org.bukkit.event.player.PlayerAnimationEvent; 5 | //import org.bukkit.event.player.PlayerAnimationType; 6 | // 7 | ///** 8 | // * Called when handling extra drops to avoid issues with NoCheat. 9 | // */ 10 | //public class FakePlayerAnimationEvent extends PlayerAnimationEvent implements FakeEvent { 11 | // public FakePlayerAnimationEvent(Player player, PlayerAnimationType playerAnimationType) { 12 | // super(player, playerAnimationType); 13 | // } 14 | //} 15 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/events/fake/FakePlayerFishEvent.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.events.fake; 2 | 3 | import org.bukkit.entity.Entity; 4 | import org.bukkit.entity.FishHook; 5 | import org.bukkit.entity.Player; 6 | import org.bukkit.event.player.PlayerFishEvent; 7 | 8 | public class FakePlayerFishEvent extends PlayerFishEvent implements FakeEvent { 9 | public FakePlayerFishEvent(Player player, Entity entity, FishHook hookEntity, State state) { 10 | super(player, entity, hookEntity, state); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/events/hardcore/McMMOPlayerPreDeathPenaltyEvent.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.events.hardcore; 2 | 3 | import org.bukkit.entity.Player; 4 | import org.bukkit.event.Cancellable; 5 | import org.bukkit.event.HandlerList; 6 | import org.bukkit.event.player.PlayerEvent; 7 | import org.jetbrains.annotations.NotNull; 8 | 9 | public class McMMOPlayerPreDeathPenaltyEvent extends PlayerEvent implements Cancellable { 10 | private boolean cancelled; 11 | 12 | public McMMOPlayerPreDeathPenaltyEvent(Player player) { 13 | super(player); 14 | this.cancelled = false; 15 | } 16 | 17 | /** Following are required for Cancellable **/ 18 | @Override 19 | public boolean isCancelled() { 20 | return cancelled; 21 | } 22 | 23 | @Override 24 | public void setCancelled(boolean cancelled) { 25 | this.cancelled = cancelled; 26 | } 27 | 28 | /** Rest of file is required boilerplate for custom events **/ 29 | private static final HandlerList handlers = new HandlerList(); 30 | 31 | @Override 32 | public @NotNull HandlerList getHandlers() { 33 | return handlers; 34 | } 35 | 36 | public static HandlerList getHandlerList() { 37 | return handlers; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/events/hardcore/McMMOPlayerStatLossEvent.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.events.hardcore; 2 | 3 | import org.bukkit.entity.Player; 4 | 5 | import java.util.HashMap; 6 | 7 | public class McMMOPlayerStatLossEvent extends McMMOPlayerDeathPenaltyEvent { 8 | 9 | public McMMOPlayerStatLossEvent(Player player, HashMap levelChanged, HashMap experienceChanged) { 10 | super(player, levelChanged, experienceChanged); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/events/hardcore/McMMOPlayerVampirismEvent.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.events.hardcore; 2 | 3 | import org.bukkit.entity.Player; 4 | 5 | import java.util.HashMap; 6 | 7 | public class McMMOPlayerVampirismEvent extends McMMOPlayerDeathPenaltyEvent { 8 | private final boolean isVictim; 9 | 10 | public McMMOPlayerVampirismEvent(Player player, boolean isVictim, HashMap levelChanged, HashMap experienceChanged) { 11 | super(player, levelChanged, experienceChanged); 12 | this.isVictim = isVictim; 13 | } 14 | 15 | public boolean isVictim() { 16 | return isVictim; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/events/party/McMMOPartyTeleportEvent.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.events.party; 2 | 3 | import org.bukkit.entity.Player; 4 | import org.bukkit.event.HandlerList; 5 | import org.bukkit.event.player.PlayerTeleportEvent; 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | /** 9 | * Called just before a player teleports using the /ptp command. 10 | */ 11 | public class McMMOPartyTeleportEvent extends PlayerTeleportEvent { 12 | private final String party; 13 | private final Player target; 14 | 15 | public McMMOPartyTeleportEvent(Player player, Player target, String party) { 16 | super(player, player.getLocation(), target.getLocation(), TeleportCause.COMMAND); 17 | this.party = party; 18 | this.target = target; 19 | } 20 | 21 | /** 22 | * @return The party the teleporting player is in 23 | */ 24 | public String getParty() { 25 | return party; 26 | } 27 | 28 | /** 29 | * @return The player being teleported to 30 | */ 31 | public Player getTarget() { 32 | return target; 33 | } 34 | 35 | /** Rest of file is required boilerplate for custom events **/ 36 | private static final HandlerList handlers = new HandlerList(); 37 | 38 | @Override 39 | public @NotNull HandlerList getHandlers() { 40 | return handlers; 41 | } 42 | 43 | public static @NotNull HandlerList getHandlerList() { 44 | return handlers; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/events/players/McMMOPlayerProfileLoadEvent.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.events.players; 2 | 3 | import com.gmail.nossr50.datatypes.player.PlayerProfile; 4 | import org.bukkit.Bukkit; 5 | import org.bukkit.entity.Player; 6 | import org.bukkit.event.Cancellable; 7 | import org.bukkit.event.Event; 8 | import org.bukkit.event.HandlerList; 9 | import org.jetbrains.annotations.NotNull; 10 | 11 | public class McMMOPlayerProfileLoadEvent extends Event implements Cancellable { 12 | private boolean cancelled; 13 | private final PlayerProfile profile; 14 | private final Player player; 15 | public McMMOPlayerProfileLoadEvent(Player player, PlayerProfile profile){ 16 | super(!Bukkit.isPrimaryThread()); 17 | 18 | this.cancelled = false; 19 | this.profile = profile; 20 | this.player = player; 21 | } 22 | @Override 23 | public boolean isCancelled() { 24 | return this.cancelled; 25 | } 26 | 27 | @Override 28 | public void setCancelled(boolean cancelled) { 29 | this.cancelled = cancelled; 30 | } 31 | 32 | public PlayerProfile getProfile(){return this.profile;} 33 | private static final HandlerList handlers = new HandlerList(); 34 | 35 | @Override 36 | public @NotNull HandlerList getHandlers() { 37 | return handlers; 38 | } 39 | 40 | public static HandlerList getHandlerList() { 41 | return handlers; 42 | } 43 | 44 | public Player getPlayer() {return player;} 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/events/scoreboard/McMMOScoreboardMakeboardEvent.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.events.scoreboard; 2 | 3 | import org.bukkit.entity.Player; 4 | import org.bukkit.scoreboard.Scoreboard; 5 | 6 | /** 7 | * This event is called when mcMMO creates its custom boards 8 | * You should not interfere with this event unless you understand our board code thoroughly 9 | * mcMMO relies on using new scoreboards to show players individually catered boards with stats specific to them 10 | */ 11 | public class McMMOScoreboardMakeboardEvent extends McMMOScoreboardEvent { 12 | public McMMOScoreboardMakeboardEvent(Scoreboard targetBoard, Scoreboard currentBoard, Player targetPlayer, ScoreboardEventReason scoreboardEventReason) { 13 | super(targetBoard, currentBoard, targetPlayer, scoreboardEventReason); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/events/scoreboard/McMMOScoreboardRevertEvent.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.events.scoreboard; 2 | 3 | import org.bukkit.entity.Player; 4 | import org.bukkit.scoreboard.Scoreboard; 5 | 6 | /** 7 | * This event is called when mcMMO is attempting to change a players targetBoard back to their previous board 8 | * This is used when an mcMMO board is cleared (removed from the screen), changing back from a temporary board (usually from a delayed scheduled task or our mcscoreboard time command) 9 | */ 10 | public class McMMOScoreboardRevertEvent extends McMMOScoreboardEvent { 11 | public McMMOScoreboardRevertEvent(Scoreboard targetBoard, Scoreboard currentBoard, Player targetPlayer, ScoreboardEventReason scoreboardEventReason) { 12 | super(targetBoard, currentBoard, targetPlayer, scoreboardEventReason); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/events/scoreboard/ScoreboardEventReason.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.events.scoreboard; 2 | 3 | public enum ScoreboardEventReason { 4 | CREATING_NEW_SCOREBOARD, 5 | OBJECTIVE, 6 | REVERTING_BOARD, 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/events/scoreboard/ScoreboardObjectiveEventReason.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.events.scoreboard; 2 | 3 | public enum ScoreboardObjectiveEventReason { 4 | UNREGISTER_THIS_OBJECTIVE, 5 | REGISTER_NEW_OBJECTIVE, 6 | } 7 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/events/skills/SkillActivationPerkEvent.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.events.skills; 2 | 3 | import org.bukkit.Bukkit; 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 | public class SkillActivationPerkEvent extends Event { 10 | 11 | 12 | 13 | 14 | private static final HandlerList handlers = new HandlerList(); 15 | private final Player player; 16 | private int ticks; 17 | private final int maxTicks; 18 | 19 | public SkillActivationPerkEvent(Player player, int ticks, int maxTicks) { 20 | super(!Bukkit.isPrimaryThread()); 21 | this.player = player; 22 | this.ticks = ticks; 23 | this.maxTicks = maxTicks; 24 | } 25 | 26 | public Player getPlayer() { 27 | return player; 28 | } 29 | 30 | public int getTicks() { 31 | return ticks; 32 | } 33 | 34 | public void setTicks(int ticks) { 35 | this.ticks = ticks; 36 | } 37 | 38 | public int getMaxTicks() { 39 | return maxTicks; 40 | } 41 | 42 | @Override 43 | public @NotNull HandlerList getHandlers() { 44 | return handlers; 45 | } 46 | 47 | public static HandlerList getHandlerList() { 48 | return handlers; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/events/skills/abilities/McMMOPlayerAbilityActivateEvent.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.events.skills.abilities; 2 | 3 | import com.gmail.nossr50.datatypes.player.McMMOPlayer; 4 | import com.gmail.nossr50.datatypes.skills.PrimarySkillType; 5 | import com.gmail.nossr50.util.player.UserManager; 6 | import org.bukkit.entity.Player; 7 | import org.bukkit.event.Cancellable; 8 | 9 | import java.util.Objects; 10 | 11 | public class McMMOPlayerAbilityActivateEvent extends McMMOPlayerAbilityEvent implements Cancellable { 12 | private boolean cancelled; 13 | 14 | @Deprecated(forRemoval = true, since = "2.2.010") 15 | public McMMOPlayerAbilityActivateEvent(Player player, PrimarySkillType skill) { 16 | super(Objects.requireNonNull(UserManager.getPlayer(player)), skill); 17 | cancelled = false; 18 | } 19 | 20 | public McMMOPlayerAbilityActivateEvent(McMMOPlayer mmoPlayer, PrimarySkillType skill) { 21 | super(mmoPlayer, skill); 22 | cancelled = false; 23 | } 24 | 25 | public boolean isCancelled() { 26 | return cancelled; 27 | } 28 | 29 | public void setCancelled(boolean value) { 30 | this.cancelled = value; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/events/skills/abilities/McMMOPlayerAbilityDeactivateEvent.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.events.skills.abilities; 2 | 3 | import com.gmail.nossr50.datatypes.player.McMMOPlayer; 4 | import com.gmail.nossr50.datatypes.skills.PrimarySkillType; 5 | import com.gmail.nossr50.util.player.UserManager; 6 | import org.bukkit.entity.Player; 7 | import org.jetbrains.annotations.NotNull; 8 | 9 | import static java.util.Objects.requireNonNull; 10 | 11 | public class McMMOPlayerAbilityDeactivateEvent extends McMMOPlayerAbilityEvent { 12 | @Deprecated(forRemoval = true, since = "2.2.010") 13 | public McMMOPlayerAbilityDeactivateEvent(@NotNull Player player, @NotNull PrimarySkillType skill) { 14 | this(requireNonNull(UserManager.getPlayer(player)), skill); 15 | } 16 | 17 | public McMMOPlayerAbilityDeactivateEvent(@NotNull McMMOPlayer mmoPlayer, @NotNull PrimarySkillType skill) { 18 | super(mmoPlayer, skill); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/events/skills/alchemy/McMMOPlayerCatalysisEvent.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.events.skills.alchemy; 2 | 3 | import com.gmail.nossr50.datatypes.player.McMMOPlayer; 4 | import com.gmail.nossr50.datatypes.skills.PrimarySkillType; 5 | import com.gmail.nossr50.events.skills.McMMOPlayerSkillEvent; 6 | import com.gmail.nossr50.util.player.UserManager; 7 | import org.bukkit.entity.Player; 8 | import org.bukkit.event.Cancellable; 9 | 10 | import static java.util.Objects.requireNonNull; 11 | 12 | public class McMMOPlayerCatalysisEvent extends McMMOPlayerSkillEvent implements Cancellable { 13 | private double speed; 14 | 15 | private boolean cancelled; 16 | 17 | @Deprecated(forRemoval = true, since = "2.2.010") 18 | public McMMOPlayerCatalysisEvent(Player player, double speed) { 19 | super(requireNonNull(UserManager.getPlayer(player)), PrimarySkillType.ALCHEMY); 20 | this.speed = speed; 21 | cancelled = false; 22 | } 23 | 24 | public McMMOPlayerCatalysisEvent(McMMOPlayer mmoPlayer, double speed) { 25 | super(mmoPlayer, PrimarySkillType.ALCHEMY); 26 | this.speed = speed; 27 | cancelled = false; 28 | } 29 | 30 | public boolean isCancelled() { 31 | return cancelled; 32 | } 33 | 34 | public void setCancelled(boolean newValue) { 35 | this.cancelled = newValue; 36 | } 37 | 38 | public double getSpeed() { 39 | return speed; 40 | } 41 | 42 | public void setSpeed(double speed) { 43 | this.speed = speed; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/events/skills/fishing/McMMOPlayerFishingEvent.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.events.skills.fishing; 2 | 3 | import com.gmail.nossr50.datatypes.player.McMMOPlayer; 4 | import com.gmail.nossr50.datatypes.skills.PrimarySkillType; 5 | import com.gmail.nossr50.events.skills.McMMOPlayerSkillEvent; 6 | import com.gmail.nossr50.util.player.UserManager; 7 | import org.bukkit.entity.Player; 8 | import org.bukkit.event.Cancellable; 9 | 10 | public class McMMOPlayerFishingEvent extends McMMOPlayerSkillEvent implements Cancellable { 11 | private boolean cancelled; 12 | 13 | @Deprecated(forRemoval = true, since = "2.2.010") 14 | protected McMMOPlayerFishingEvent(Player player) { 15 | super(UserManager.getPlayer(player), PrimarySkillType.FISHING); 16 | cancelled = false; 17 | } 18 | 19 | protected McMMOPlayerFishingEvent(McMMOPlayer mmoPlayer) { 20 | super(mmoPlayer, PrimarySkillType.FISHING); 21 | cancelled = false; 22 | } 23 | 24 | public boolean isCancelled() { 25 | return cancelled; 26 | } 27 | 28 | public void setCancelled(boolean newValue) { 29 | this.cancelled = newValue; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/events/skills/fishing/McMMOPlayerFishingTreasureEvent.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.events.skills.fishing; 2 | 3 | import com.gmail.nossr50.datatypes.player.McMMOPlayer; 4 | import com.gmail.nossr50.util.player.UserManager; 5 | import org.bukkit.entity.Player; 6 | import org.bukkit.inventory.ItemStack; 7 | import org.jetbrains.annotations.NotNull; 8 | import org.jetbrains.annotations.Nullable; 9 | 10 | import static java.util.Objects.requireNonNull; 11 | 12 | public class McMMOPlayerFishingTreasureEvent extends McMMOPlayerFishingEvent { 13 | private ItemStack treasure; 14 | private int xp; 15 | 16 | @Deprecated(forRemoval = true, since = "2.2.010") 17 | public McMMOPlayerFishingTreasureEvent(Player player, ItemStack treasure, int xp) { 18 | this(requireNonNull(UserManager.getPlayer(player)), treasure, xp); 19 | } 20 | 21 | public McMMOPlayerFishingTreasureEvent(@NotNull McMMOPlayer mmoPlayer, @Nullable ItemStack treasure, int xp) { 22 | super(mmoPlayer); 23 | this.treasure = treasure; 24 | this.xp = xp; 25 | } 26 | 27 | public @Nullable ItemStack getTreasure() { 28 | return treasure; 29 | } 30 | 31 | public void setTreasure(@Nullable ItemStack item) { 32 | this.treasure = item; 33 | } 34 | 35 | public int getXp() { 36 | return xp; 37 | } 38 | 39 | public void setXp(int xp) { 40 | this.xp = xp; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/events/skills/fishing/McMMOPlayerMagicHunterEvent.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.events.skills.fishing; 2 | 3 | import com.gmail.nossr50.datatypes.player.McMMOPlayer; 4 | import com.gmail.nossr50.util.player.UserManager; 5 | import org.bukkit.enchantments.Enchantment; 6 | import org.bukkit.entity.Player; 7 | import org.bukkit.inventory.ItemStack; 8 | import org.jetbrains.annotations.NotNull; 9 | 10 | import java.util.HashMap; 11 | import java.util.Map; 12 | 13 | import static java.util.Objects.requireNonNull; 14 | 15 | public class McMMOPlayerMagicHunterEvent extends McMMOPlayerFishingTreasureEvent { 16 | private final Map enchants = new HashMap<>(); 17 | 18 | @Deprecated(forRemoval = true, since = "2.2.010") 19 | public McMMOPlayerMagicHunterEvent(@NotNull Player player, @NotNull ItemStack treasure, int xp, @NotNull Map enchants) { 20 | this(requireNonNull(UserManager.getPlayer(player)), treasure, xp, enchants); 21 | } 22 | 23 | public McMMOPlayerMagicHunterEvent(@NotNull McMMOPlayer mmoPlayer, @NotNull ItemStack treasure, int xp, @NotNull Map enchants) { 24 | super(mmoPlayer, treasure, xp); 25 | requireNonNull(enchants, "enchants cannot be null"); 26 | this.enchants.putAll(enchants); 27 | } 28 | 29 | public @NotNull Map getEnchantments() { 30 | return enchants; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/events/skills/fishing/McMMOPlayerShakeEvent.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.events.skills.fishing; 2 | 3 | import org.bukkit.entity.Player; 4 | import org.bukkit.inventory.ItemStack; 5 | 6 | public class McMMOPlayerShakeEvent extends McMMOPlayerFishingEvent { 7 | private ItemStack drop; 8 | 9 | public McMMOPlayerShakeEvent(Player player, ItemStack drop) { 10 | super(player); 11 | this.drop = drop; 12 | } 13 | 14 | public ItemStack getDrop() { 15 | return drop; 16 | } 17 | 18 | public void setDrop(ItemStack drop) { 19 | this.drop = drop; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/events/skills/secondaryabilities/SubSkillBlockEvent.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.events.skills.secondaryabilities; 2 | 3 | import com.gmail.nossr50.datatypes.skills.SubSkillType; 4 | import org.bukkit.block.Block; 5 | import org.bukkit.entity.Player; 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | public class SubSkillBlockEvent extends SubSkillEvent { 9 | private final @NotNull Block block; 10 | 11 | public SubSkillBlockEvent(@NotNull Player player, @NotNull SubSkillType subSkillType, @NotNull Block block) { 12 | super(player, subSkillType); 13 | this.block = block; 14 | } 15 | 16 | /** 17 | * Get the block associated with this event 18 | * @return the block associated with this event 19 | */ 20 | public @NotNull Block getBlock() { 21 | return block; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/events/skills/secondaryabilities/SubSkillRandomCheckEvent.java: -------------------------------------------------------------------------------- 1 | //package com.gmail.nossr50.events.skills.secondaryabilities; 2 | // 3 | //import com.gmail.nossr50.datatypes.skills.SubSkillType; 4 | //import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill; 5 | //import org.bukkit.entity.Player; 6 | // 7 | //public class SubSkillRandomCheckEvent extends SubSkillEvent { 8 | // private double chance; 9 | // 10 | // public SubSkillRandomCheckEvent(Player player, SubSkillType ability, double chance) { 11 | // super(player, ability); 12 | // this.chance = chance; 13 | // } 14 | // 15 | // /** 16 | // * Gets the activation chance of the ability 0D being no chance, 100.0D being 100% chance 17 | // * 18 | // * @return The activation chance of the ability 19 | // */ 20 | // public double getChance() { 21 | // return chance; 22 | // } 23 | // 24 | // /** 25 | // * Sets the activation chance of the ability [0D-100.0D] 26 | // * 27 | // * @param chance The activation chance of the ability 28 | // */ 29 | // public void setChance(double chance) { 30 | // this.chance = chance; 31 | // } 32 | // 33 | // /** 34 | // * Sets the activation chance of the ability to 100% or 0% 35 | // * 36 | // * @param success whether it should be successful or not 37 | // */ 38 | // public void setSuccessful(boolean success) { 39 | // this.chance = success ? 100.0D : 0D; 40 | // } 41 | //} 42 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/events/skills/unarmed/McMMOPlayerDisarmEvent.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.events.skills.unarmed; 2 | 3 | import com.gmail.nossr50.datatypes.skills.PrimarySkillType; 4 | import com.gmail.nossr50.events.skills.McMMOPlayerSkillEvent; 5 | import org.bukkit.entity.Player; 6 | import org.bukkit.event.Cancellable; 7 | 8 | public class McMMOPlayerDisarmEvent extends McMMOPlayerSkillEvent implements Cancellable { 9 | private boolean cancelled; 10 | private final Player defender; 11 | 12 | public McMMOPlayerDisarmEvent(Player defender) { 13 | super(defender, PrimarySkillType.UNARMED); 14 | this.defender = defender; 15 | } 16 | 17 | public Player getDefender() { 18 | return defender; 19 | } 20 | 21 | /** Following are required for Cancellable **/ 22 | @Override 23 | public boolean isCancelled() { 24 | return cancelled; 25 | } 26 | 27 | @Override 28 | public void setCancelled(boolean cancelled) { 29 | this.cancelled = cancelled; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/listeners/ChunkListener.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.listeners; 2 | 3 | import com.gmail.nossr50.mcMMO; 4 | import org.bukkit.Chunk; 5 | import org.bukkit.entity.LivingEntity; 6 | import org.bukkit.event.EventHandler; 7 | import org.bukkit.event.Listener; 8 | import org.bukkit.event.world.ChunkUnloadEvent; 9 | 10 | import java.util.Arrays; 11 | 12 | public class ChunkListener implements Listener { 13 | 14 | @EventHandler(ignoreCancelled = true, priority = org.bukkit.event.EventPriority.MONITOR) 15 | public void onChunkUnload(ChunkUnloadEvent event) { 16 | final Chunk unloadingChunk = event.getChunk(); 17 | 18 | // Avoid processing if chunk is null or unloaded 19 | if (unloadingChunk == null || !unloadingChunk.isLoaded() || unloadingChunk.getEntities() == null) { 20 | return; 21 | } 22 | 23 | try { 24 | Arrays.stream(unloadingChunk.getEntities()) 25 | .filter(entity -> entity instanceof LivingEntity) 26 | .map(entity -> (LivingEntity) entity) 27 | .forEach(livingEntity -> mcMMO.getTransientEntityTracker().removeTrackedEntity(livingEntity)); 28 | } catch (Exception ex) { 29 | mcMMO.p.getLogger().warning("Caught exception during chunk unload event processing: " + ex.getMessage()); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/metadata/MobMetaFlagType.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.metadata; 2 | 3 | public enum MobMetaFlagType { 4 | MOB_SPAWNER_MOB, 5 | EGG_MOB, 6 | NETHER_PORTAL_MOB, 7 | COTW_SUMMONED_MOB, 8 | PLAYER_BRED_MOB, 9 | PLAYER_TAMED_MOB, 10 | EXPLOITED_ENDERMEN, 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/placeholders/PartyIsLeaderPlaceholder.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.placeholders; 2 | 3 | import org.bukkit.entity.Player; 4 | 5 | public class PartyIsLeaderPlaceholder implements Placeholder { 6 | 7 | private final PapiExpansion papiExpansion; 8 | 9 | public PartyIsLeaderPlaceholder(PapiExpansion papiExpansion) { 10 | this.papiExpansion = papiExpansion; 11 | } 12 | 13 | /** 14 | * {@inheritDoc} 15 | */ 16 | @Override 17 | public String process(Player player, String params) { 18 | String leader = papiExpansion.getPartyLeader(player); 19 | return (leader.equals(player.getName())) ? "true" : "false"; 20 | } 21 | 22 | /** 23 | * {@inheritDoc} 24 | */ 25 | @Override 26 | public String getName() { 27 | return "is_party_leader"; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/placeholders/PartyIsMemberPlaceholder.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.placeholders; 2 | 3 | import org.bukkit.entity.Player; 4 | 5 | public class PartyIsMemberPlaceholder implements Placeholder { 6 | 7 | private final PapiExpansion papiExpansion; 8 | public PartyIsMemberPlaceholder(PapiExpansion papiExpansion) { 9 | this.papiExpansion = papiExpansion; 10 | } 11 | 12 | @Override 13 | public String process(Player player, String params) { 14 | return (papiExpansion.getPartyName(player) == null) ? "false" : "true"; 15 | } 16 | 17 | @Override 18 | public String getName() { 19 | return "in_party"; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/placeholders/PartyLeaderPlaceholder.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.placeholders; 2 | 3 | import org.apache.commons.lang3.StringUtils; 4 | import org.bukkit.entity.Player; 5 | 6 | public class PartyLeaderPlaceholder implements Placeholder { 7 | private final PapiExpansion papiExpansion; 8 | 9 | public PartyLeaderPlaceholder(PapiExpansion papiExpansion) { 10 | this.papiExpansion = papiExpansion; 11 | } 12 | 13 | @Override 14 | public String process(Player player, String params) { 15 | return StringUtils.trimToEmpty(papiExpansion.getPartyLeader(player)); 16 | } 17 | 18 | @Override 19 | public String getName() { 20 | return "party_leader"; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/placeholders/PartyNamePlaceholder.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.placeholders; 2 | 3 | import org.apache.commons.lang3.StringUtils; 4 | import org.bukkit.entity.Player; 5 | 6 | public class PartyNamePlaceholder implements Placeholder { 7 | private final PapiExpansion papiExpansion; 8 | 9 | public PartyNamePlaceholder(PapiExpansion papiExpansion) { 10 | this.papiExpansion = papiExpansion; 11 | } 12 | 13 | @Override 14 | public String process(Player player, String params) { 15 | return StringUtils.trimToEmpty(papiExpansion.getPartyName(player)); 16 | } 17 | 18 | @Override 19 | public String getName() { 20 | return "party_name"; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/placeholders/PartySizePlaceholder.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.placeholders; 2 | 3 | import org.bukkit.entity.Player; 4 | 5 | public class PartySizePlaceholder implements Placeholder { 6 | private final PapiExpansion papiExpansion; 7 | 8 | public PartySizePlaceholder(PapiExpansion papiExpansion) { 9 | this.papiExpansion = papiExpansion; 10 | } 11 | 12 | @Override 13 | public String process(Player player, String params) { 14 | Integer partySize = papiExpansion.getPartySize(player); 15 | return (partySize == null) ? "" : partySize.toString(); 16 | } 17 | 18 | @Override 19 | public String getName() { 20 | return "party_size"; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/placeholders/Placeholder.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.placeholders; 2 | 3 | import org.bukkit.entity.Player; 4 | 5 | public interface Placeholder { 6 | 7 | /** 8 | * @param player the player to process the placeholder for 9 | * @param params the paramaters to be passed to the placeholder 10 | * @return the value of the placeholder 11 | */ 12 | String process(Player player, String params); 13 | 14 | /** 15 | * @return the name of the placeholder 16 | */ 17 | String getName(); 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/placeholders/PowerLevelCapPlaceholder.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.placeholders; 2 | 3 | import org.bukkit.entity.Player; 4 | 5 | public class PowerLevelCapPlaceholder implements Placeholder { 6 | private final PapiExpansion papiExpansion; 7 | 8 | public PowerLevelCapPlaceholder(PapiExpansion papiExpansion) { 9 | this.papiExpansion = papiExpansion; 10 | } 11 | 12 | @Override 13 | public String process(Player player, String params) { 14 | Integer cap = papiExpansion.getPowerCap(player); 15 | return (cap == null) ? "" : cap.toString(); 16 | } 17 | 18 | @Override 19 | public String getName() { 20 | return "power_level_cap"; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/placeholders/PowerLevelPlaceholder.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.placeholders; 2 | 3 | import org.bukkit.entity.Player; 4 | 5 | public class PowerLevelPlaceholder implements Placeholder { 6 | private final PapiExpansion papiExpansion; 7 | 8 | public PowerLevelPlaceholder(PapiExpansion papiExpansion) { 9 | this.papiExpansion = papiExpansion; 10 | } 11 | 12 | @Override 13 | public String process(Player player, String params) { 14 | Integer powerLevel = papiExpansion.getPowerLevel(player); 15 | return (powerLevel == null) ? "" : powerLevel.toString(); 16 | } 17 | 18 | @Override 19 | public String getName() { 20 | return "power_level"; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/placeholders/SkillExpNeededPlaceholder.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.placeholders; 2 | 3 | import com.gmail.nossr50.datatypes.skills.PrimarySkillType; 4 | import org.bukkit.entity.Player; 5 | 6 | public class SkillExpNeededPlaceholder implements Placeholder { 7 | 8 | private final PapiExpansion papiExpansion; 9 | private final PrimarySkillType skillType; 10 | 11 | public SkillExpNeededPlaceholder(PapiExpansion papiExpansion, PrimarySkillType skillType) { 12 | this.papiExpansion = papiExpansion; 13 | this.skillType = skillType; 14 | } 15 | 16 | @Override 17 | public String process(Player player, String params) { 18 | final Integer expNeeded = papiExpansion.getExpNeeded(skillType, player); 19 | return (expNeeded == null) ? "" : expNeeded.toString(); 20 | } 21 | 22 | @Override 23 | public String getName() { 24 | return "xp_needed_" + skillType.toString().toLowerCase(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/placeholders/SkillExpPlaceholder.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.placeholders; 2 | 3 | import com.gmail.nossr50.datatypes.skills.PrimarySkillType; 4 | import org.bukkit.entity.Player; 5 | 6 | public class SkillExpPlaceholder implements Placeholder { 7 | private final PapiExpansion papiExpansion; 8 | private final PrimarySkillType skill; 9 | 10 | public SkillExpPlaceholder(PapiExpansion papiExpansion, PrimarySkillType skill) { 11 | this.papiExpansion = papiExpansion; 12 | this.skill = skill; 13 | } 14 | 15 | 16 | @Override 17 | public String process(Player player, String params) { 18 | Integer exp = papiExpansion.getExp(skill, player); 19 | return (exp == null) ? "" : exp.toString(); 20 | } 21 | 22 | @Override 23 | public String getName() { 24 | return "xp_" + skill.toString().toLowerCase(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/placeholders/SkillExpRemainingPlaceholder.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.placeholders; 2 | 3 | import com.gmail.nossr50.datatypes.skills.PrimarySkillType; 4 | import org.bukkit.entity.Player; 5 | 6 | public class SkillExpRemainingPlaceholder implements Placeholder { 7 | private final PapiExpansion papiExpansion; 8 | private final PrimarySkillType skill; 9 | 10 | public SkillExpRemainingPlaceholder(PapiExpansion papiExpansion, PrimarySkillType skill) { 11 | this.papiExpansion = papiExpansion; 12 | this.skill = skill; 13 | } 14 | 15 | @Override 16 | public String process(Player player, String params) { 17 | final Integer expRemaining = papiExpansion.getExpRemaining(skill, player); 18 | return (expRemaining == null) ? "" : expRemaining.toString(); 19 | } 20 | 21 | @Override 22 | public String getName() { 23 | return "xp_remaining_" + skill.toString().toLowerCase(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/placeholders/SkillLevelPlaceholder.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.placeholders; 2 | 3 | import com.gmail.nossr50.datatypes.skills.PrimarySkillType; 4 | import org.bukkit.entity.Player; 5 | 6 | public class SkillLevelPlaceholder implements Placeholder { 7 | private final PapiExpansion papiExpansion; 8 | private final PrimarySkillType skillType; 9 | 10 | public SkillLevelPlaceholder(PapiExpansion papiExpansion, PrimarySkillType skillType) { 11 | this.papiExpansion = papiExpansion; 12 | this.skillType = skillType; 13 | } 14 | 15 | @Override 16 | public String process(Player p, String params) { 17 | final Integer skillLevel = papiExpansion.getSkillLevel(skillType, p); 18 | return (skillLevel == null) ? "" : skillLevel.toString(); 19 | } 20 | 21 | @Override 22 | public String getName() { 23 | return "level_" + skillType.toString().toLowerCase(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/placeholders/SkillRankPlaceholder.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.placeholders; 2 | 3 | import com.gmail.nossr50.datatypes.skills.PrimarySkillType; 4 | import org.bukkit.entity.Player; 5 | 6 | public class SkillRankPlaceholder implements Placeholder { 7 | private final PapiExpansion papiExpansion; 8 | private final PrimarySkillType skill; 9 | 10 | public SkillRankPlaceholder(PapiExpansion papiExpansion, PrimarySkillType skill) { 11 | this.papiExpansion = papiExpansion; 12 | this.skill = skill; 13 | } 14 | 15 | @Override 16 | public String process(Player player, String params) { 17 | Integer rank = papiExpansion.getRank(skill, player); 18 | return (rank == null) ? "" : rank.toString(); 19 | } 20 | 21 | @Override 22 | public String getName() { 23 | return "rank_" + skill.toString().toLowerCase(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/placeholders/SkillXpRatePlaceholder.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.placeholders; 2 | 3 | import com.gmail.nossr50.datatypes.skills.PrimarySkillType; 4 | import org.bukkit.entity.Player; 5 | 6 | public class SkillXpRatePlaceholder implements Placeholder { 7 | private final PapiExpansion papiExpansion; 8 | private final PrimarySkillType skillType; 9 | 10 | public SkillXpRatePlaceholder(PapiExpansion papiExpansion, PrimarySkillType skillType) { 11 | this.papiExpansion = papiExpansion; 12 | this.skillType = skillType; 13 | } 14 | 15 | @Override 16 | public String process(Player p, String params) { 17 | final String skillLevel = papiExpansion.getSkillXpRate(skillType, p); 18 | return (skillLevel == null) ? "" : skillLevel; 19 | } 20 | 21 | @Override 22 | public String getName() { 23 | return "xprate_" + skillType.toString().toLowerCase(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/placeholders/XpEventActivePlaceholder.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.placeholders; 2 | 3 | import com.gmail.nossr50.datatypes.skills.PrimarySkillType; 4 | import org.bukkit.entity.Player; 5 | 6 | public class XpEventActivePlaceholder implements Placeholder { 7 | private final PapiExpansion papiExpansion; 8 | 9 | public XpEventActivePlaceholder(PapiExpansion papiExpansion) { 10 | this.papiExpansion = papiExpansion; 11 | } 12 | 13 | @Override 14 | public String process(Player player, String params) { 15 | return papiExpansion.isExpEventActive(player); 16 | } 17 | 18 | @Override 19 | public String getName() { 20 | return "is_xp_event_active"; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/placeholders/XpRatePlaceholder.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.placeholders; 2 | 3 | import com.gmail.nossr50.datatypes.skills.PrimarySkillType; 4 | import org.bukkit.entity.Player; 5 | 6 | public class XpRatePlaceholder implements Placeholder { 7 | private final PapiExpansion papiExpansion; 8 | 9 | public XpRatePlaceholder(PapiExpansion papiExpansion) { 10 | this.papiExpansion = papiExpansion; 11 | } 12 | 13 | @Override 14 | public String process(Player player, String params) { 15 | return papiExpansion.getXpRate(player); 16 | } 17 | 18 | @Override 19 | public String getName() { 20 | return "xprate"; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/protocollib/ProtocolLibManager.java: -------------------------------------------------------------------------------- 1 | //package com.gmail.nossr50.protocollib; 2 | // 3 | //import com.gmail.nossr50.mcMMO; 4 | //import org.bukkit.Bukkit; 5 | //import org.bukkit.entity.Player; 6 | //import org.bukkit.plugin.Plugin; 7 | // 8 | //public class ProtocolLibManager { 9 | // final Plugin protocolLibPluginRef; 10 | // final mcMMO pluginRef; 11 | // final ProtocolHandler protocolHandler; 12 | // 13 | // public ProtocolLibManager(mcMMO pluginRef) { 14 | // this.pluginRef = pluginRef; 15 | // 16 | // if (isProtocolLibPresent()) { 17 | // protocolLibPluginRef = pluginRef.getServer().getPluginManager().getPlugin("ProtocolLib"); 18 | // protocolHandler = new ProtocolHandler(pluginRef); 19 | // pluginRef.getLogger().info("ProtocolLib found, enabling ProtocolLib features."); 20 | // } else { 21 | // protocolLibPluginRef = null; 22 | // protocolHandler = null; 23 | // pluginRef.getLogger().info("No ProtocolLib found, some completely optional cosmetic features will not be enabled."); 24 | // } 25 | // } 26 | // 27 | // public boolean usingProtocolLib() { 28 | // return protocolLibPluginRef != null && protocolHandler != null; 29 | // } 30 | // 31 | // private boolean isProtocolLibPresent() { 32 | // return Bukkit.getServer().getPluginManager().getPlugin("ProtocolLib") != null; 33 | // } 34 | // 35 | // public void sendPacketToPlayer(Player player) { 36 | // if (usingProtocolLib()) { 37 | // protocolHandler.sendPacketToPlayer(player); 38 | // } 39 | // } 40 | //} 41 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/runnables/CheckDateTask.java: -------------------------------------------------------------------------------- 1 | //package com.gmail.nossr50.runnables; 2 | // 3 | //import com.gmail.nossr50.mcMMO; 4 | //import com.gmail.nossr50.runnables.skills.AprilTask; 5 | //import com.gmail.nossr50.util.Misc; 6 | //import com.gmail.nossr50.util.CancellableRunnable; 7 | // 8 | //public class CheckDateTask extends CancellableRunnable { 9 | // 10 | // @Override 11 | // public void run() { 12 | // if (!mcMMO.getHolidayManager().isAprilFirst()) { 13 | // return; 14 | // } 15 | // 16 | // // Set up jokes 17 | // new AprilTask().runTaskTimer(mcMMO.p, 60L * Misc.TICK_CONVERSION_FACTOR, 10L * 60L * Misc.TICK_CONVERSION_FACTOR); 18 | // mcMMO.getHolidayManager().registerAprilCommand(); 19 | // 20 | // // Jokes deployed. 21 | // this.cancel(); 22 | // } 23 | //} 24 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/runnables/MobDodgeMetaCleanup.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.runnables; 2 | 3 | import com.gmail.nossr50.mcMMO; 4 | import com.gmail.nossr50.util.CancellableRunnable; 5 | import com.gmail.nossr50.util.MetadataConstants; 6 | import org.bukkit.entity.Mob; 7 | import org.jetbrains.annotations.NotNull; 8 | 9 | public class MobDodgeMetaCleanup extends CancellableRunnable { 10 | private final @NotNull Mob mob; 11 | private final @NotNull mcMMO pluginRef; 12 | 13 | public MobDodgeMetaCleanup(@NotNull Mob mob, @NotNull mcMMO pluginRef) { 14 | this.mob = mob; 15 | this.pluginRef = pluginRef; 16 | } 17 | 18 | @Override 19 | public void run() { 20 | if (!mob.isValid() || mob.getTarget() == null) { 21 | mob.removeMetadata(MetadataConstants.METADATA_KEY_DODGE_TRACKER, pluginRef); 22 | this.cancel(); 23 | } else if (!mob.hasMetadata(MetadataConstants.METADATA_KEY_DODGE_TRACKER)) { 24 | this.cancel(); 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/runnables/MobHealthDisplayUpdaterTask.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.runnables; 2 | 3 | import com.gmail.nossr50.mcMMO; 4 | import com.gmail.nossr50.util.CancellableRunnable; 5 | import com.gmail.nossr50.util.MetadataConstants; 6 | import org.bukkit.entity.LivingEntity; 7 | 8 | public class MobHealthDisplayUpdaterTask extends CancellableRunnable { 9 | private final LivingEntity target; 10 | 11 | public MobHealthDisplayUpdaterTask(LivingEntity target) { 12 | this.target = target; 13 | } 14 | 15 | @Override 16 | public void run() { 17 | if (target.hasMetadata(MetadataConstants.METADATA_KEY_CUSTOM_NAME)) { 18 | target.setCustomName(target.getMetadata(MetadataConstants.METADATA_KEY_CUSTOM_NAME).get(0).asString()); 19 | target.removeMetadata(MetadataConstants.METADATA_KEY_CUSTOM_NAME, mcMMO.p); 20 | } 21 | 22 | if (target.hasMetadata(MetadataConstants.METADATA_KEY_NAME_VISIBILITY)) { 23 | target.setCustomNameVisible(target.getMetadata(MetadataConstants.METADATA_KEY_NAME_VISIBILITY).get(0).asBoolean()); 24 | target.removeMetadata(MetadataConstants.METADATA_KEY_NAME_VISIBILITY, mcMMO.p); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/runnables/SaveTimerTask.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.runnables; 2 | 3 | import com.gmail.nossr50.datatypes.player.McMMOPlayer; 4 | import com.gmail.nossr50.mcMMO; 5 | import com.gmail.nossr50.runnables.player.PlayerProfileSaveTask; 6 | import com.gmail.nossr50.util.CancellableRunnable; 7 | import com.gmail.nossr50.util.LogUtils; 8 | import com.gmail.nossr50.util.player.UserManager; 9 | 10 | public class SaveTimerTask extends CancellableRunnable { 11 | @Override 12 | public void run() { 13 | LogUtils.debug(mcMMO.p.getLogger(), "[User Data] Saving..."); 14 | // All player data will be saved periodically through this 15 | int count = 1; 16 | 17 | for (McMMOPlayer mcMMOPlayer : UserManager.getPlayers()) { 18 | mcMMO.p.getFoliaLib().getScheduler().runLaterAsync(new PlayerProfileSaveTask(mcMMOPlayer.getProfile(), false), count); 19 | count++; 20 | } 21 | 22 | if (mcMMO.p.getPartyConfig().isPartyEnabled()) 23 | mcMMO.p.getPartyManager().saveParties(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/runnables/StickyPistonTrackerTask.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.runnables; 2 | 3 | import com.gmail.nossr50.mcMMO; 4 | import com.gmail.nossr50.util.BlockUtils; 5 | import com.gmail.nossr50.util.CancellableRunnable; 6 | import org.bukkit.block.Block; 7 | import org.bukkit.block.BlockFace; 8 | 9 | public class StickyPistonTrackerTask extends CancellableRunnable { 10 | private final BlockFace direction; 11 | private final Block block; 12 | private final Block movedBlock; 13 | 14 | public StickyPistonTrackerTask(BlockFace direction, Block block, Block movedBlock) { 15 | this.direction = direction; 16 | this.block = block; 17 | this.movedBlock = movedBlock; 18 | } 19 | 20 | @Override 21 | public void run() { 22 | if (!mcMMO.getUserBlockTracker().isIneligible(movedBlock.getRelative(direction))) { 23 | return; 24 | } 25 | 26 | if (!BlockUtils.isPistonPiece(movedBlock.getState())) { 27 | // The block didn't move 28 | return; 29 | } 30 | 31 | // The sticky piston actually pulled the block so move the PlaceStore data 32 | mcMMO.getUserBlockTracker().setEligible(movedBlock.getRelative(direction)); 33 | BlockUtils.setUnnaturalBlock(movedBlock); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/runnables/TravelingBlockMetaCleanup.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.runnables; 2 | 3 | import com.gmail.nossr50.mcMMO; 4 | import com.gmail.nossr50.util.CancellableRunnable; 5 | import com.gmail.nossr50.util.MetadataConstants; 6 | import org.bukkit.entity.Entity; 7 | import org.jetbrains.annotations.NotNull; 8 | 9 | public class TravelingBlockMetaCleanup extends CancellableRunnable { 10 | private final @NotNull Entity entity; 11 | private final @NotNull mcMMO pluginRef; 12 | 13 | public TravelingBlockMetaCleanup(@NotNull Entity entity, @NotNull mcMMO pluginRef) { 14 | this.entity = entity; 15 | this.pluginRef = pluginRef; 16 | } 17 | 18 | @Override 19 | public void run() { 20 | if (!entity.isValid()) { 21 | entity.removeMetadata(MetadataConstants.METADATA_KEY_TRAVELING_BLOCK, pluginRef); 22 | this.cancel(); 23 | } else if (!entity.hasMetadata(MetadataConstants.METADATA_KEY_TRAVELING_BLOCK)) { 24 | this.cancel(); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/runnables/commands/McRankCommandAsyncTask.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.runnables.commands; 2 | 3 | import com.gmail.nossr50.datatypes.skills.PrimarySkillType; 4 | import com.gmail.nossr50.mcMMO; 5 | import com.gmail.nossr50.util.CancellableRunnable; 6 | import org.apache.commons.lang3.Validate; 7 | import org.bukkit.command.CommandSender; 8 | import org.bukkit.entity.Player; 9 | 10 | import java.util.Map; 11 | 12 | public class McRankCommandAsyncTask extends CancellableRunnable { 13 | private final String playerName; 14 | private final CommandSender sender; 15 | private final boolean useBoard, useChat; 16 | 17 | public McRankCommandAsyncTask(String playerName, CommandSender sender, boolean useBoard, boolean useChat) { 18 | Validate.isTrue(useBoard || useChat, "Attempted to start a rank retrieval with both board and chat off"); 19 | Validate.notNull(sender, "Attempted to start a rank retrieval with no recipient"); 20 | 21 | if (useBoard) { 22 | Validate.isTrue(sender instanceof Player, "Attempted to start a rank retrieval displaying scoreboard to a non-player"); 23 | } 24 | 25 | this.playerName = playerName; 26 | this.sender = sender; 27 | this.useBoard = useBoard; 28 | this.useChat = useChat; 29 | } 30 | 31 | @Override 32 | public void run() { 33 | Map skills = mcMMO.getDatabaseManager().readRank(playerName); 34 | 35 | mcMMO.p.getFoliaLib().getScheduler().runNextTick(new McRankCommandDisplayTask(skills, sender, playerName, useBoard, useChat)); 36 | } 37 | } 38 | 39 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/runnables/commands/McScoreboardKeepTask.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.runnables.commands; 2 | 3 | import com.gmail.nossr50.util.CancellableRunnable; 4 | import com.gmail.nossr50.util.scoreboards.ScoreboardManager; 5 | import org.bukkit.entity.Player; 6 | 7 | public class McScoreboardKeepTask extends CancellableRunnable { 8 | private final Player player; 9 | 10 | public McScoreboardKeepTask(Player player) { 11 | this.player = player; 12 | } 13 | 14 | @Override 15 | public void run() { 16 | if (player.isValid() && ScoreboardManager.isBoardShown(player.getName())) { 17 | ScoreboardManager.keepBoard(player.getName()); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/runnables/commands/NotifySquelchReminderTask.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.runnables.commands; 2 | 3 | import com.gmail.nossr50.locale.LocaleLoader; 4 | import com.gmail.nossr50.util.CancellableRunnable; 5 | import com.gmail.nossr50.util.player.UserManager; 6 | import org.bukkit.Bukkit; 7 | import org.bukkit.entity.Player; 8 | 9 | public class NotifySquelchReminderTask extends CancellableRunnable { 10 | 11 | @Override 12 | public void run() { 13 | for (Player player : Bukkit.getOnlinePlayers()) { 14 | if (UserManager.getPlayer(player) != null) { 15 | if (!UserManager.getPlayer(player).useChatNotifications()) { 16 | player.sendMessage(LocaleLoader.getString("Reminder.Squelched")); 17 | } 18 | } 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/runnables/database/DatabaseConversionTask.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.runnables.database; 2 | 3 | import com.gmail.nossr50.database.DatabaseManager; 4 | import com.gmail.nossr50.locale.LocaleLoader; 5 | import com.gmail.nossr50.mcMMO; 6 | import com.gmail.nossr50.util.CancellableRunnable; 7 | import org.bukkit.command.CommandSender; 8 | 9 | public class DatabaseConversionTask extends CancellableRunnable { 10 | private final DatabaseManager sourceDatabase; 11 | private final CommandSender sender; 12 | private final String message; 13 | 14 | public DatabaseConversionTask(DatabaseManager sourceDatabase, CommandSender sender, String oldType, String newType) { 15 | this.sourceDatabase = sourceDatabase; 16 | this.sender = sender; 17 | message = LocaleLoader.getString("Commands.mcconvert.Database.Finish", oldType, newType); 18 | } 19 | 20 | @Override 21 | public void run() { 22 | sourceDatabase.convertUsers(mcMMO.getDatabaseManager()); 23 | 24 | mcMMO.p.getFoliaLib().getScheduler().runNextTick(t -> sender.sendMessage(message)); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/runnables/database/UserPurgeTask.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.runnables.database; 2 | 3 | import com.gmail.nossr50.mcMMO; 4 | import com.gmail.nossr50.util.CancellableRunnable; 5 | 6 | import java.util.concurrent.locks.ReentrantLock; 7 | 8 | public class UserPurgeTask extends CancellableRunnable { 9 | private final ReentrantLock lock = new ReentrantLock(); 10 | @Override 11 | public void run() { 12 | lock.lock(); 13 | mcMMO.getDatabaseManager().purgePowerlessUsers(); 14 | 15 | if (mcMMO.p.getGeneralConfig().getOldUsersCutoff() != -1) { 16 | mcMMO.getDatabaseManager().purgeOldUsers(); 17 | } 18 | lock.unlock(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/runnables/player/ClearRegisteredXPGainTask.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.runnables.player; 2 | 3 | import com.gmail.nossr50.datatypes.player.McMMOPlayer; 4 | import com.gmail.nossr50.util.CancellableRunnable; 5 | import com.gmail.nossr50.util.player.UserManager; 6 | 7 | public class ClearRegisteredXPGainTask extends CancellableRunnable { 8 | @Override 9 | public void run() { 10 | for (McMMOPlayer mcMMOPlayer : UserManager.getPlayers()) { 11 | mcMMOPlayer.getProfile().purgeExpiredXpGains(); 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/runnables/player/PlayerProfileSaveTask.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.runnables.player; 2 | 3 | import com.gmail.nossr50.datatypes.player.PlayerProfile; 4 | import com.gmail.nossr50.util.CancellableRunnable; 5 | 6 | public class PlayerProfileSaveTask extends CancellableRunnable { 7 | private final PlayerProfile playerProfile; 8 | private final boolean isSync; 9 | 10 | public PlayerProfileSaveTask(PlayerProfile playerProfile, boolean isSync) { 11 | this.playerProfile = playerProfile; 12 | this.isSync = isSync; 13 | } 14 | 15 | @Override 16 | public void run() { 17 | playerProfile.save(isSync); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/runnables/player/PlayerUpdateInventoryTask.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.runnables.player; 2 | 3 | import com.gmail.nossr50.util.CancellableRunnable; 4 | import org.bukkit.entity.Player; 5 | 6 | @SuppressWarnings("deprecation") 7 | public class PlayerUpdateInventoryTask extends CancellableRunnable { 8 | private final Player player; 9 | 10 | public PlayerUpdateInventoryTask(Player player) { 11 | this.player = player; 12 | } 13 | 14 | @Override 15 | public void run() { 16 | player.updateInventory(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/runnables/player/PowerLevelUpdatingTask.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.runnables.player; 2 | 3 | import com.gmail.nossr50.util.CancellableRunnable; 4 | import com.gmail.nossr50.util.scoreboards.ScoreboardManager; 5 | 6 | public class PowerLevelUpdatingTask extends CancellableRunnable { 7 | @Override 8 | public void run() { 9 | if (!ScoreboardManager.powerLevelHeartbeat()) { 10 | this.cancel(); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/runnables/skills/AbilityCooldownTask.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.runnables.skills; 2 | 3 | import com.gmail.nossr50.datatypes.interactions.NotificationType; 4 | import com.gmail.nossr50.datatypes.player.McMMOPlayer; 5 | import com.gmail.nossr50.datatypes.skills.SuperAbilityType; 6 | import com.gmail.nossr50.util.CancellableRunnable; 7 | import com.gmail.nossr50.util.player.NotificationManager; 8 | 9 | public class AbilityCooldownTask extends CancellableRunnable { 10 | private final McMMOPlayer mcMMOPlayer; 11 | private final SuperAbilityType ability; 12 | 13 | public AbilityCooldownTask(McMMOPlayer mcMMOPlayer, SuperAbilityType ability) { 14 | this.mcMMOPlayer = mcMMOPlayer; 15 | this.ability = ability; 16 | } 17 | 18 | @Override 19 | public void run() { 20 | if (!mcMMOPlayer.getPlayer().isOnline() || mcMMOPlayer.getAbilityInformed(ability)) { 21 | return; 22 | } 23 | 24 | mcMMOPlayer.setAbilityInformed(ability, true); // TODO: ?? What does this do again? 25 | NotificationManager.sendPlayerInformation(mcMMOPlayer.getPlayer(), NotificationType.ABILITY_REFRESHED, ability.getAbilityRefresh()); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/runnables/skills/BleedContainer.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.runnables.skills; 2 | 3 | import org.bukkit.entity.LivingEntity; 4 | 5 | public class BleedContainer { 6 | public int bleedTicks; 7 | public int bleedRank; 8 | public int toolTier; 9 | public LivingEntity target; 10 | public LivingEntity damageSource; 11 | 12 | public BleedContainer(LivingEntity target, int bleedTicks, int bleedRank, int toolTier, LivingEntity damageSource) { 13 | this.target = target; 14 | this.bleedTicks = bleedTicks; 15 | this.bleedRank = bleedRank; 16 | this.toolTier = toolTier; 17 | this.damageSource = damageSource; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/runnables/skills/DelayedHerbalismXPCheckTask.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.runnables.skills; 2 | 3 | import com.gmail.nossr50.datatypes.BlockSnapshot; 4 | import com.gmail.nossr50.datatypes.player.McMMOPlayer; 5 | import com.gmail.nossr50.util.CancellableRunnable; 6 | 7 | import java.util.ArrayList; 8 | 9 | public class DelayedHerbalismXPCheckTask extends CancellableRunnable { 10 | 11 | private final McMMOPlayer mcMMOPlayer; 12 | private final ArrayList chorusBlocks; 13 | 14 | public DelayedHerbalismXPCheckTask(McMMOPlayer mcMMOPlayer, ArrayList chorusBlocks) { 15 | this.mcMMOPlayer = mcMMOPlayer; 16 | this.chorusBlocks = chorusBlocks; 17 | } 18 | 19 | @Override 20 | public void run() { 21 | mcMMOPlayer.getHerbalismManager().awardXPForBlockSnapshots(chorusBlocks); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/runnables/skills/HerbalismBlockUpdaterTask.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.runnables.skills; 2 | 3 | import com.gmail.nossr50.util.CancellableRunnable; 4 | import org.bukkit.block.BlockState; 5 | 6 | public class HerbalismBlockUpdaterTask extends CancellableRunnable { 7 | private final BlockState blockState; 8 | 9 | public HerbalismBlockUpdaterTask(BlockState blockState) { 10 | this.blockState = blockState; 11 | } 12 | 13 | @Override 14 | public void run() { 15 | blockState.update(true); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/runnables/skills/MasterAnglerTask.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.runnables.skills; 2 | 3 | import com.gmail.nossr50.skills.fishing.FishingManager; 4 | import com.gmail.nossr50.util.CancellableRunnable; 5 | import org.bukkit.entity.FishHook; 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | public class MasterAnglerTask extends CancellableRunnable { 9 | private final @NotNull FishHook fishHook; 10 | private final @NotNull FishingManager fishingManager; 11 | private final int lureLevel; 12 | 13 | public MasterAnglerTask(@NotNull FishHook fishHook, @NotNull FishingManager fishingManager, int lureLevel) { 14 | this.fishHook = fishHook; 15 | this.fishingManager = fishingManager; 16 | this.lureLevel = lureLevel; 17 | } 18 | 19 | @Override 20 | public void run() { 21 | fishingManager.processMasterAngler(fishHook, lureLevel); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/runnables/skills/ToolLowerTask.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.runnables.skills; 2 | 3 | import com.gmail.nossr50.datatypes.interactions.NotificationType; 4 | import com.gmail.nossr50.datatypes.player.McMMOPlayer; 5 | import com.gmail.nossr50.datatypes.skills.ToolType; 6 | import com.gmail.nossr50.mcMMO; 7 | import com.gmail.nossr50.util.CancellableRunnable; 8 | import com.gmail.nossr50.util.player.NotificationManager; 9 | 10 | public class ToolLowerTask extends CancellableRunnable { 11 | private final McMMOPlayer mcMMOPlayer; 12 | private final ToolType tool; 13 | 14 | public ToolLowerTask(McMMOPlayer mcMMOPlayer, ToolType tool) { 15 | this.mcMMOPlayer = mcMMOPlayer; 16 | this.tool = tool; 17 | } 18 | 19 | @Override 20 | public void run() { 21 | if (!mcMMOPlayer.getToolPreparationMode(tool)) { 22 | return; 23 | } 24 | 25 | mcMMOPlayer.setToolPreparationMode(tool, false); 26 | 27 | if (mcMMO.p.getGeneralConfig().getAbilityMessagesEnabled()) { 28 | NotificationManager.sendPlayerInformation(mcMMOPlayer.getPlayer(), NotificationType.TOOL, tool.getLowerTool()); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/skills/acrobatics/Acrobatics.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.skills.acrobatics; 2 | 3 | import com.gmail.nossr50.config.experience.ExperienceConfig; 4 | import com.gmail.nossr50.mcMMO; 5 | 6 | public final class Acrobatics { 7 | public static double dodgeDamageModifier = mcMMO.p.getAdvancedConfig().getDodgeDamageModifier(); 8 | public static int dodgeXpModifier = ExperienceConfig.getInstance().getDodgeXPModifier(); 9 | public static boolean dodgeLightningDisabled = mcMMO.p.getGeneralConfig().getDodgeLightningDisabled(); 10 | 11 | private Acrobatics() {} 12 | 13 | protected static double calculateModifiedDodgeDamage(double damage, double damageModifier) { 14 | return Math.max(damage / damageModifier, 1.0); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/skills/alchemy/Alchemy.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.skills.alchemy; 2 | 3 | import com.gmail.nossr50.mcMMO; 4 | import com.gmail.nossr50.runnables.skills.AlchemyBrewTask; 5 | import com.gmail.nossr50.util.LogUtils; 6 | import org.bukkit.Location; 7 | 8 | import java.util.ArrayList; 9 | import java.util.HashMap; 10 | import java.util.List; 11 | import java.util.Map; 12 | 13 | public final class Alchemy { 14 | public static final int INGREDIENT_SLOT = 3; 15 | 16 | public static int catalysisMaxBonusLevel = mcMMO.p.getAdvancedConfig().getCatalysisMaxBonusLevel(); 17 | public static double catalysisMinSpeed = mcMMO.p.getAdvancedConfig().getCatalysisMinSpeed(); 18 | public static double catalysisMaxSpeed = mcMMO.p.getAdvancedConfig().getCatalysisMaxSpeed(); 19 | 20 | public static Map brewingStandMap = new HashMap<>(); 21 | 22 | private Alchemy() {} 23 | 24 | /** 25 | * Finish all active brews. Used upon Disable to prevent vanilla potions from being brewed upon next Enable. 26 | */ 27 | public static void finishAllBrews() { 28 | LogUtils.debug(mcMMO.p.getLogger(), "Completing " + brewingStandMap.size() + " unfinished Alchemy brews."); 29 | 30 | List toFinish = new ArrayList<>(brewingStandMap.values()); 31 | 32 | for (AlchemyBrewTask alchemyBrewTask : toFinish) { 33 | alchemyBrewTask.finishImmediately(); 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/skills/archery/TrackedEntity.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.skills.archery; 2 | 3 | import com.gmail.nossr50.mcMMO; 4 | import com.gmail.nossr50.util.CancellableRunnable; 5 | import org.bukkit.entity.LivingEntity; 6 | 7 | import java.util.UUID; 8 | 9 | public class TrackedEntity extends CancellableRunnable { 10 | private final LivingEntity livingEntity; 11 | private final UUID id; 12 | private int arrowCount; 13 | 14 | protected TrackedEntity(LivingEntity livingEntity) { 15 | this.livingEntity = livingEntity; 16 | this.id = livingEntity.getUniqueId(); 17 | 18 | mcMMO.p.getFoliaLib().getScheduler().runAtEntityTimer(livingEntity, this, 12000, 12000); 19 | } 20 | 21 | @Override 22 | public void run() { 23 | if (!livingEntity.isValid()) { 24 | Archery.removeFromTracker(this); 25 | this.cancel(); 26 | } 27 | } 28 | 29 | protected LivingEntity getLivingEntity() { 30 | return livingEntity; 31 | } 32 | 33 | protected UUID getID() { 34 | return id; 35 | } 36 | 37 | protected int getArrowCount() { 38 | return arrowCount; 39 | } 40 | 41 | protected void incrementArrowCount() { 42 | arrowCount++; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/skills/excavation/Excavation.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.skills.excavation; 2 | 3 | import com.gmail.nossr50.config.treasure.TreasureConfig; 4 | import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure; 5 | import org.bukkit.block.Block; 6 | 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | 10 | import static com.gmail.nossr50.util.text.ConfigStringUtils.getMaterialConfigString; 11 | 12 | public class Excavation { 13 | /** 14 | * Get the list of possible {@link ExcavationTreasure|ExcavationTreasures} obtained from a given block. 15 | * 16 | * @param block The {@link Block} to check for treasures 17 | * @return the list of treasures that could be found 18 | */ 19 | protected static List getTreasures(Block block) { 20 | String friendly = getMaterialConfigString(block.getBlockData().getMaterial()); 21 | if (TreasureConfig.getInstance().excavationMap.containsKey(friendly)) 22 | return TreasureConfig.getInstance().excavationMap.get(friendly); 23 | return new ArrayList<>(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/skills/repair/ArcaneForging.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.skills.repair; 2 | 3 | import com.gmail.nossr50.mcMMO; 4 | 5 | public class ArcaneForging { 6 | 7 | public static boolean arcaneForgingDowngrades = mcMMO.p.getAdvancedConfig().getArcaneForgingDowngradeEnabled(); 8 | public static boolean arcaneForgingEnchantLoss = mcMMO.p.getAdvancedConfig().getArcaneForgingEnchantLossEnabled(); 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/skills/repair/Repair.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.skills.repair; 2 | 3 | import com.gmail.nossr50.datatypes.skills.SubSkillType; 4 | import com.gmail.nossr50.mcMMO; 5 | import org.bukkit.Material; 6 | 7 | public class Repair { 8 | public static int repairMasteryMaxBonusLevel = mcMMO.p.getAdvancedConfig().getMaxBonusLevel(SubSkillType.REPAIR_REPAIR_MASTERY); 9 | public static double repairMasteryMaxBonus = mcMMO.p.getAdvancedConfig().getRepairMasteryMaxBonus(); 10 | 11 | public static Material anvilMaterial = mcMMO.p.getGeneralConfig().getRepairAnvilMaterial(); 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/skills/repair/repairables/RepairableManager.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.skills.repair.repairables; 2 | 3 | import org.bukkit.Material; 4 | import org.bukkit.inventory.ItemStack; 5 | 6 | import java.util.List; 7 | 8 | public interface RepairableManager { 9 | /** 10 | * Register a repairable with the RepairManager 11 | * 12 | * @param repairable Repairable to register 13 | */ 14 | void registerRepairable(Repairable repairable); 15 | 16 | /** 17 | * Register a list of repairables with the RepairManager 18 | * 19 | * @param repairables List to register 20 | */ 21 | void registerRepairables(List repairables); 22 | 23 | /** 24 | * Checks if an item is repairable 25 | * 26 | * @param type Material to check if repairable 27 | * 28 | * @return true if repairable, false if not 29 | */ 30 | boolean isRepairable(Material type); 31 | 32 | /** 33 | * Checks if an item is repairable 34 | * 35 | * @param itemStack Item to check if repairable 36 | * 37 | * @return true if repairable, false if not 38 | */ 39 | boolean isRepairable(ItemStack itemStack); 40 | 41 | /** 42 | * Gets the repairable with this type 43 | * 44 | * @param type Material of the repairable to look for 45 | * 46 | * @return the repairable, can be null 47 | */ 48 | Repairable getRepairable(Material type); 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/skills/repair/repairables/SimpleRepairableManager.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.skills.repair.repairables; 2 | 3 | import org.bukkit.Material; 4 | import org.bukkit.inventory.ItemStack; 5 | 6 | import java.util.HashMap; 7 | import java.util.List; 8 | 9 | public class SimpleRepairableManager implements RepairableManager { 10 | private final HashMap repairables; 11 | 12 | public SimpleRepairableManager() { 13 | this(55); 14 | } 15 | 16 | public SimpleRepairableManager(int repairablesSize) { 17 | this.repairables = new HashMap<>(repairablesSize); 18 | } 19 | 20 | @Override 21 | public void registerRepairable(Repairable repairable) { 22 | Material item = repairable.getItemMaterial(); 23 | repairables.put(item, repairable); 24 | } 25 | 26 | @Override 27 | public void registerRepairables(List repairables) { 28 | for (Repairable repairable : repairables) { 29 | registerRepairable(repairable); 30 | } 31 | } 32 | 33 | @Override 34 | public boolean isRepairable(Material type) { 35 | return repairables.containsKey(type); 36 | } 37 | 38 | @Override 39 | public boolean isRepairable(ItemStack itemStack) { 40 | return isRepairable(itemStack.getType()); 41 | } 42 | 43 | @Override 44 | public Repairable getRepairable(Material type) { 45 | return repairables.get(type); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/skills/salvage/Salvage.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.skills.salvage; 2 | 3 | import com.gmail.nossr50.mcMMO; 4 | import org.bukkit.Material; 5 | 6 | public final class Salvage { 7 | 8 | /** 9 | * This is a static utility class, therefore we don't want any instances of 10 | * this class. Making the constructor private prevents accidents like that. 11 | */ 12 | private Salvage() {} 13 | 14 | public static Material anvilMaterial = mcMMO.p.getGeneralConfig().getSalvageAnvilMaterial(); 15 | 16 | /*public static int salvageMaxPercentageLevel = mcMMO.p.getAdvancedConfig().getSalvageMaxPercentageLevel(); 17 | public static double salvageMaxPercentage = mcMMO.p.getAdvancedConfig().getSalvageMaxPercentage(); 18 | 19 | public static int advancedSalvageUnlockLevel = RankUtils.getRankUnlockLevel(SubSkillType.SALVAGE_SCRAP_COLLECTOR, 1);*/ 20 | 21 | public static boolean arcaneSalvageDowngrades = mcMMO.p.getAdvancedConfig().getArcaneSalvageEnchantDowngradeEnabled(); 22 | public static boolean arcaneSalvageEnchantLoss = mcMMO.p.getAdvancedConfig().getArcaneSalvageEnchantLossEnabled(); 23 | 24 | static int calculateSalvageableAmount(int currentDurability, short maxDurability, int baseAmount) { 25 | double percentDamaged = (maxDurability <= 0) ? 1D : (double) (maxDurability - currentDurability) / maxDurability; 26 | 27 | return (int) Math.floor(baseAmount * percentDamaged); 28 | } 29 | } -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/skills/salvage/salvageables/SalvageableFactory.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.skills.salvage.salvageables; 2 | 3 | import com.gmail.nossr50.datatypes.skills.ItemType; 4 | import com.gmail.nossr50.datatypes.skills.MaterialType; 5 | import org.bukkit.Material; 6 | 7 | public final class SalvageableFactory { 8 | /** 9 | * This is a static utility class, therefore we don't want any instances of 10 | * this class. Making the constructor private prevents accidents like that. 11 | */ 12 | private SalvageableFactory() {} 13 | 14 | public static Salvageable getSalvageable(Material itemMaterial, Material recipeMaterial, int maximumQuantity, short maximumDurability) { 15 | return getSalvageable(itemMaterial, recipeMaterial, 0, maximumQuantity, maximumDurability, ItemType.OTHER, MaterialType.OTHER, 1); 16 | } 17 | 18 | public static Salvageable getSalvageable(Material itemMaterial, Material recipeMaterial, int minimumLevel, int maximumQuantity, short maximumDurability, ItemType repairItemType, MaterialType repairMaterialType, double xpMultiplier) { 19 | // TODO: Add in loading from config what type of repairable we want. 20 | return new SimpleSalvageable(itemMaterial, recipeMaterial, minimumLevel, maximumQuantity, maximumDurability, repairItemType, repairMaterialType, xpMultiplier); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/skills/salvage/salvageables/SalvageableManager.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.skills.salvage.salvageables; 2 | 3 | import org.bukkit.Material; 4 | import org.bukkit.inventory.ItemStack; 5 | 6 | import java.util.List; 7 | 8 | public interface SalvageableManager { 9 | /** 10 | * Register a salvageable with the SalvageManager 11 | * 12 | * @param salvageable Salvageable to register 13 | */ 14 | void registerSalvageable(Salvageable salvageable); 15 | 16 | /** 17 | * Register a list of salvageables with the SalvageManager 18 | * 19 | * @param salvageables List to register 20 | */ 21 | void registerSalvageables(List salvageables); 22 | 23 | /** 24 | * Checks if an item is salvageable 25 | * 26 | * @param type Material to check if salvageable 27 | * 28 | * @return true if salvageable, false if not 29 | */ 30 | boolean isSalvageable(Material type); 31 | 32 | /** 33 | * Checks if an item is salvageable 34 | * 35 | * @param itemStack Item to check if salvageable 36 | * 37 | * @return true if salvageable, false if not 38 | */ 39 | boolean isSalvageable(ItemStack itemStack); 40 | 41 | /** 42 | * Gets the salvageable with this type 43 | * 44 | * @param type Material of the salvageable to look for 45 | * 46 | * @return the salvageable, can be null 47 | */ 48 | Salvageable getSalvageable(Material type); 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/skills/salvage/salvageables/SimpleSalvageableManager.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.skills.salvage.salvageables; 2 | 3 | import org.bukkit.Material; 4 | import org.bukkit.inventory.ItemStack; 5 | 6 | import java.util.HashMap; 7 | import java.util.List; 8 | import java.util.Map; 9 | 10 | public class SimpleSalvageableManager implements SalvageableManager { 11 | private final Map salvageables; 12 | 13 | public SimpleSalvageableManager() { 14 | this(55); 15 | } 16 | 17 | public SimpleSalvageableManager(int salvageablesSize) { 18 | this.salvageables = new HashMap<>(salvageablesSize); 19 | } 20 | 21 | @Override 22 | public void registerSalvageable(Salvageable salvageable) { 23 | Material item = salvageable.getItemMaterial(); 24 | salvageables.put(item, salvageable); 25 | } 26 | 27 | @Override 28 | public void registerSalvageables(List salvageables) { 29 | for (Salvageable salvageable : salvageables) { 30 | registerSalvageable(salvageable); 31 | } 32 | } 33 | 34 | @Override 35 | public boolean isSalvageable(Material type) { 36 | return salvageables.containsKey(type); 37 | } 38 | 39 | @Override 40 | public boolean isSalvageable(ItemStack itemStack) { 41 | return isSalvageable(itemStack.getType()); 42 | } 43 | 44 | @Override 45 | public Salvageable getSalvageable(Material type) { 46 | return salvageables.get(type); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/skills/smelting/Smelting.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.skills.smelting; 2 | 3 | import com.gmail.nossr50.config.experience.ExperienceConfig; 4 | import com.gmail.nossr50.datatypes.skills.PrimarySkillType; 5 | import org.bukkit.inventory.ItemStack; 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | public class Smelting { 9 | 10 | public static int getSmeltXP(@NotNull ItemStack smelting) { 11 | return ExperienceConfig.getInstance().getXp(PrimarySkillType.SMELTING, smelting.getType()); 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/skills/swords/Swords.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.skills.swords; 2 | 3 | import com.gmail.nossr50.mcMMO; 4 | 5 | public class Swords { 6 | public static double counterAttackModifier = mcMMO.p.getAdvancedConfig().getCounterModifier(); 7 | 8 | public static double serratedStrikesModifier = mcMMO.p.getAdvancedConfig().getSerratedStrikesModifier(); 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/skills/tridents/TridentsManager.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.skills.tridents; 2 | 3 | import com.gmail.nossr50.datatypes.player.McMMOPlayer; 4 | import com.gmail.nossr50.datatypes.skills.PrimarySkillType; 5 | import com.gmail.nossr50.datatypes.skills.SubSkillType; 6 | import com.gmail.nossr50.skills.SkillManager; 7 | import com.gmail.nossr50.util.skills.RankUtils; 8 | 9 | public class TridentsManager extends SkillManager { 10 | public TridentsManager(McMMOPlayer mmoPlayer) { 11 | super(mmoPlayer, PrimarySkillType.TRIDENTS); 12 | } 13 | 14 | public double impaleDamageBonus() { 15 | int rank = RankUtils.getRank(getPlayer(), SubSkillType.TRIDENTS_IMPALE); 16 | 17 | if (rank > 1) { 18 | return (1.0D + (rank * .5D)); 19 | } else if (rank == 1) { 20 | return 1.0D; 21 | } 22 | 23 | return 0.0D; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/skills/woodcutting/Woodcutting.java: -------------------------------------------------------------------------------- 1 | //package com.gmail.nossr50.skills.woodcutting; 2 | // 3 | //import com.gmail.nossr50.config.Config; 4 | //import com.gmail.nossr50.config.experience.ExperienceConfig; 5 | //import com.gmail.nossr50.datatypes.skills.PrimarySkillType; 6 | //import com.gmail.nossr50.mcMMO; 7 | //import com.gmail.nossr50.util.BlockUtils; 8 | //import com.gmail.nossr50.util.Misc; 9 | //import com.gmail.nossr50.util.skills.SkillUtils; 10 | //import org.bukkit.Material; 11 | //import org.bukkit.block.BlockFace; 12 | //import org.bukkit.block.BlockState; 13 | //import org.bukkit.inventory.ItemStack; 14 | // 15 | //import java.util.ArrayList; 16 | //import java.util.List; 17 | //import java.util.Set; 18 | // 19 | //public final class Woodcutting { 20 | // public static int treeFellerThreshold = Config.getInstance().getTreeFellerThreshold(); 21 | // 22 | // private Woodcutting() {} 23 | // 24 | // 25 | // 26 | // 27 | //} 28 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/util/CancellableRunnable.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.util; 2 | 3 | import com.tcoded.folialib.wrapper.task.WrappedTask; 4 | 5 | import java.util.function.Consumer; 6 | 7 | public abstract class CancellableRunnable implements Consumer { 8 | private boolean cancelled = false; 9 | 10 | public void cancel() { 11 | cancelled = true; 12 | } 13 | 14 | public abstract void run(); 15 | 16 | @Override 17 | public void accept(WrappedTask wrappedTask) { 18 | // Run the task if it hasn't been cancelled 19 | if (!cancelled) { 20 | run(); 21 | } 22 | 23 | // Cancel the task if it has been cancelled after running 24 | if (cancelled) { 25 | wrappedTask.cancel(); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/util/LogFilter.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.util; 2 | 3 | import com.gmail.nossr50.mcMMO; 4 | 5 | import java.util.logging.Filter; 6 | import java.util.logging.LogRecord; 7 | 8 | import static com.gmail.nossr50.util.LogUtils.DEBUG_STR; 9 | 10 | public class LogFilter implements Filter { 11 | private final boolean debug; 12 | 13 | public LogFilter(mcMMO plugin) { 14 | // Doing a config loading lite here, because we can't depend on the config loader to have loaded before any debug messages are sent 15 | debug = plugin.getConfig().getBoolean("General.Verbose_Logging"); 16 | } 17 | 18 | @Override 19 | public boolean isLoggable(LogRecord record) { 20 | return !(record.getMessage().contains(DEBUG_STR) && !debug); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/util/LogUtils.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.util; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | 5 | import java.util.logging.Logger; 6 | 7 | public class LogUtils { 8 | 9 | public static final String DEBUG_STR = "[D] "; 10 | 11 | public static void debug(@NotNull Logger logger, @NotNull String message) { 12 | logger.info(DEBUG_STR + message); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/util/MaterialUtils.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.util; 2 | 3 | import com.gmail.nossr50.mcMMO; 4 | import org.bukkit.Material; 5 | 6 | public final class MaterialUtils { 7 | private MaterialUtils() {} 8 | 9 | protected static boolean isOre(Material data) { 10 | return mcMMO.getMaterialMapStore().isOre(data.getKey().getKey()); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/util/PotionCompatibilityType.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.util; 2 | 3 | public enum PotionCompatibilityType { 4 | PRE_1_20_5, 5 | MODERN 6 | } 7 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/util/blockmeta/ChunkManager.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.util.blockmeta; 2 | 3 | import org.bukkit.World; 4 | import org.jetbrains.annotations.NotNull; 5 | 6 | public interface ChunkManager extends UserBlockTracker { 7 | void closeAll(); 8 | void chunkUnloaded(int cx, int cz, @NotNull World world); 9 | void unloadWorld(@NotNull World world); 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/util/blockmeta/ChunkManagerFactory.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.util.blockmeta; 2 | 3 | import com.gmail.nossr50.config.PersistentDataConfig; 4 | import org.jetbrains.annotations.NotNull; 5 | 6 | public class ChunkManagerFactory { 7 | public static @NotNull ChunkManager getChunkManager() { 8 | 9 | if (PersistentDataConfig.getInstance().useBlockTracker()) { 10 | return new HashChunkManager(); 11 | } 12 | 13 | return new NullChunkManager(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/util/blockmeta/NullChunkManager.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.util.blockmeta; 2 | 3 | import org.bukkit.World; 4 | import org.bukkit.block.Block; 5 | import org.bukkit.block.BlockState; 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | public class NullChunkManager implements ChunkManager { 9 | 10 | @Override 11 | public void closeAll() {} 12 | 13 | @Override 14 | public void chunkUnloaded(int cx, int cz, @NotNull World world) {} 15 | 16 | @Override 17 | public void unloadWorld(@NotNull World world) {} 18 | 19 | @Override 20 | public boolean isIneligible(@NotNull Block block) { 21 | return false; 22 | } 23 | 24 | @Override 25 | public boolean isIneligible(@NotNull BlockState blockState) { 26 | return false; 27 | } 28 | 29 | @Override 30 | public boolean isEligible(@NotNull Block block) { 31 | return true; 32 | } 33 | 34 | @Override 35 | public boolean isEligible(@NotNull BlockState blockState) { 36 | return true; 37 | } 38 | 39 | @Override 40 | public void setIneligible(@NotNull Block block) {} 41 | 42 | @Override 43 | public void setIneligible(@NotNull BlockState blockState) {} 44 | 45 | @Override 46 | public void setEligible(@NotNull Block block) {} 47 | 48 | @Override 49 | public void setEligible(@NotNull BlockState blockState) {} 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/util/compat/CompatibilityLayer.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.util.compat; 2 | 3 | /** 4 | * Compatibility Layers should be named after the functionality they serve 5 | */ 6 | public interface CompatibilityLayer { 7 | /** 8 | * Whether this CompatibilityLayer successfully initialized and in theory should be functional 9 | * @return true if this CompatibilityLayer is functional 10 | */ 11 | default boolean noErrorsOnInitialize() { return true; }; 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/util/compat/CompatibilityType.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.util.compat; 2 | 3 | public enum CompatibilityType { 4 | PERSISTENT_DATA, 5 | BUNGEE_SERIALIZER, 6 | MASTER_ANGLER, 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/util/compat/layers/AbstractCompatibilityLayer.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.util.compat.layers; 2 | 3 | import com.gmail.nossr50.util.compat.CompatibilityLayer; 4 | 5 | /** 6 | * 7 | * These classes are a band-aid solution for adding NMS support into 2.1.XXX 8 | * In 2.2 we are switching to modules and that will clean things up significantly 9 | * 10 | */ 11 | public abstract class AbstractCompatibilityLayer implements CompatibilityLayer { 12 | 13 | protected boolean noErrorsOnInitialize = true; 14 | 15 | /** 16 | * Initialize the CompatibilityLayer 17 | * @return true if the CompatibilityLayer initialized and should be functional 18 | */ 19 | public abstract boolean initializeLayer(); 20 | 21 | @Override 22 | public boolean noErrorsOnInitialize() { 23 | return noErrorsOnInitialize; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/util/compat/layers/AbstractNMSCompatibilityLayer.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.util.compat.layers; 2 | 3 | import com.gmail.nossr50.util.nms.NMSVersion; 4 | import org.jetbrains.annotations.NotNull; 5 | 6 | /** 7 | * 8 | * These classes are a band-aid solution for adding NMS support into 2.1.XXX 9 | * In 2.2 we are switching to modules and that will clean things up significantly 10 | * 11 | */ 12 | public abstract class AbstractNMSCompatibilityLayer extends AbstractCompatibilityLayer { 13 | 14 | protected final @NotNull NMSVersion nmsVersion; 15 | 16 | public AbstractNMSCompatibilityLayer(@NotNull NMSVersion nmsVersion) { 17 | this.nmsVersion = nmsVersion; 18 | } 19 | 20 | /** 21 | * Initialize the CompatibilityLayer 22 | * @return true if the CompatibilityLayer initialized and should be functional 23 | */ 24 | public abstract boolean initializeLayer(); 25 | 26 | @Override 27 | public boolean noErrorsOnInitialize() { 28 | return noErrorsOnInitialize; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/util/compat/layers/attackcooldown/PlayerAttackCooldownMethods.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.util.compat.layers.attackcooldown; 2 | 3 | import org.bukkit.entity.Player; 4 | import org.jetbrains.annotations.NotNull; 5 | 6 | import java.lang.reflect.InvocationTargetException; 7 | 8 | public interface PlayerAttackCooldownMethods { 9 | /** 10 | * Grabs the attack strength for a player 11 | * Should be noted that as of today there is no way to capture a players current attack strength in spigot when they attack an entity outside of network packet listening 12 | * @param player target player 13 | * @return the float value of the player's attack strength 14 | */ 15 | float getAttackStrength(@NotNull Player player) throws InvocationTargetException, IllegalAccessException; 16 | 17 | float getCooldownValue(@NotNull Player player) throws InvocationTargetException, IllegalAccessException; 18 | 19 | void resetAttackStrength(@NotNull Player player) throws InvocationTargetException, IllegalAccessException; 20 | 21 | int getCooldownFieldValue(@NotNull Player player) throws InvocationTargetException, IllegalAccessException; 22 | 23 | void setCooldownFieldValue(@NotNull Player player, int fieldValue) throws InvocationTargetException, IllegalAccessException; 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/util/compat/layers/bungee/AbstractBungeeSerializerCompatibilityLayer.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.util.compat.layers.bungee; 2 | 3 | import net.kyori.adventure.text.Component; 4 | import net.md_5.bungee.api.chat.BaseComponent; 5 | import org.checkerframework.checker.nullness.qual.NonNull; 6 | 7 | public abstract class AbstractBungeeSerializerCompatibilityLayer { 8 | 9 | public abstract @NonNull Component deserialize(final @NonNull BaseComponent @NonNull[] input); 10 | 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/util/compat/layers/bungee/BungeeLegacySerializerCompatibilityLayer.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.util.compat.layers.bungee; 2 | 3 | import net.kyori.adventure.text.Component; 4 | import net.kyori.adventure.text.serializer.bungeecord.BungeeComponentSerializer; 5 | import net.md_5.bungee.api.chat.BaseComponent; 6 | import org.checkerframework.checker.nullness.qual.NonNull; 7 | 8 | public class BungeeLegacySerializerCompatibilityLayer extends AbstractBungeeSerializerCompatibilityLayer { 9 | @Override 10 | public @NonNull Component deserialize(@NonNull BaseComponent @NonNull [] input) { 11 | return BungeeComponentSerializer.legacy().deserialize(input); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/util/compat/layers/bungee/BungeeModernSerializerCompatibilityLayer.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.util.compat.layers.bungee; 2 | 3 | import net.kyori.adventure.text.Component; 4 | import net.kyori.adventure.text.serializer.bungeecord.BungeeComponentSerializer; 5 | import net.md_5.bungee.api.chat.BaseComponent; 6 | import org.checkerframework.checker.nullness.qual.NonNull; 7 | 8 | public class BungeeModernSerializerCompatibilityLayer extends AbstractBungeeSerializerCompatibilityLayer { 9 | @Override 10 | public @NonNull Component deserialize(@NonNull BaseComponent @NonNull [] input) { 11 | return BungeeComponentSerializer.get().deserialize(input); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/util/compat/layers/skills/AbstractMasterAnglerCompatibility.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.util.compat.layers.skills; 2 | 3 | import com.gmail.nossr50.util.compat.layers.AbstractCompatibilityLayer; 4 | 5 | public abstract class AbstractMasterAnglerCompatibility extends AbstractCompatibilityLayer { 6 | } 7 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/util/nms/NMSVersion.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.util.nms; 2 | 3 | public enum NMSVersion { 4 | //1.8 5 | NMS_1_8_8("1.8.8"), 6 | 7 | //1.12 8 | NMS_1_12_2("1.12.2"), 9 | 10 | //1.13 11 | NMS_1_13_2("1.13.2"), 12 | 13 | //1.14 14 | NMS_1_14_4("1.14.4"), 15 | 16 | //1.15 17 | NMS_1_15_2("1.15.2"), 18 | 19 | //1.16 20 | NMS_1_16_1("1.16.1"), 21 | NMS_1_16_2("1.16.2"), 22 | NMS_1_16_3("1.16.3"), 23 | NMS_1_16_4("1.16.4"), 24 | NMS_1_16_5("1.16.5"), 25 | NMS_1_17("1.17"), 26 | 27 | //Version not known to this build of mcMMO 28 | UNSUPPORTED("unsupported"); 29 | 30 | private final String sanitizedVersionNumber; 31 | 32 | NMSVersion(String sanitizedVersionNumber) { 33 | this.sanitizedVersionNumber = sanitizedVersionNumber; 34 | } 35 | 36 | /** 37 | * The standardized major.minor.patch {@link String} for the current NMS mappings 38 | * 39 | * @return the standardized major.minor.patch version string, patch is omitted if it is not a patch version 40 | */ 41 | public String getSanitizedVersionNumber() { 42 | return sanitizedVersionNumber; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/util/platform/AbstractPlatform.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.util.platform; 2 | 3 | import com.gmail.nossr50.util.compat.CompatibilityManager; 4 | 5 | /** 6 | * 7 | * These classes are a band-aid solution for adding NMS support into 2.1.XXX 8 | * In 2.2 we are switching to modules and that will clean things up significantly 9 | * 10 | */ 11 | public abstract class AbstractPlatform implements Platform{ 12 | 13 | protected final CompatibilityManager compatibilityManager; 14 | protected final MinecraftGameVersion minecraftGameVersion; 15 | protected final ServerSoftwareType serverSoftwareType; 16 | 17 | public AbstractPlatform(MinecraftGameVersion minecraftGameVersion, ServerSoftwareType serverSoftwareType, CompatibilityManager compatibilityManager) { 18 | this.minecraftGameVersion = minecraftGameVersion; 19 | this.serverSoftwareType = serverSoftwareType; 20 | this.compatibilityManager = compatibilityManager; 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/util/platform/BukkitPlatform.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.util.platform; 2 | 3 | import com.gmail.nossr50.util.compat.CompatibilityManager; 4 | import org.jetbrains.annotations.NotNull; 5 | 6 | /** 7 | * 8 | * These classes are a band-aid solution for adding NMS support into 2.1.XXX 9 | * In 2.2 we are switching to modules and that will clean things up significantly 10 | * 11 | */ 12 | public class BukkitPlatform extends AbstractPlatform { 13 | public BukkitPlatform(MinecraftGameVersion minecraftGameVersion) { 14 | super(minecraftGameVersion, ServerSoftwareType.CRAFT_BUKKIT, new CompatibilityManager(minecraftGameVersion)); 15 | } 16 | 17 | @Override 18 | public @NotNull ServerSoftwareType getServerSoftwareType() { 19 | return super.serverSoftwareType; 20 | } 21 | 22 | @Override 23 | public @NotNull CompatibilityManager getCompatibilityManager() { 24 | return compatibilityManager; 25 | } 26 | 27 | @Override 28 | public @NotNull MinecraftGameVersion getGameVersion() { 29 | return super.minecraftGameVersion; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/util/platform/Platform.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.util.platform; 2 | 3 | import com.gmail.nossr50.util.compat.CompatibilityManager; 4 | import org.jetbrains.annotations.NotNull; 5 | 6 | /** 7 | * 8 | * These classes are a band-aid solution for adding NMS support into 2.1.XXX 9 | * In 2.2 we are switching to modules and that will clean things up significantly 10 | * 11 | */ 12 | public interface Platform { 13 | 14 | /** 15 | * Target {@link ServerSoftwareType} for this {@link Platform} 16 | * @return the {@link ServerSoftwareType} for this {@link Platform} 17 | */ 18 | @NotNull ServerSoftwareType getServerSoftwareType(); 19 | 20 | /** 21 | * Get the {@link CompatibilityManager} for this {@link Platform} 22 | * @return the {@link CompatibilityManager} for this platform 23 | */ 24 | @NotNull CompatibilityManager getCompatibilityManager(); 25 | 26 | /** 27 | * The target game version of this {@link Platform} 28 | * @return the target {@link MinecraftGameVersion} of this {@link Platform} 29 | */ 30 | @NotNull MinecraftGameVersion getGameVersion(); 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/util/platform/PlatformBuilder.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.util.platform; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | import org.jetbrains.annotations.Nullable; 5 | 6 | /** 7 | * 8 | * These classes are a band-aid solution for adding NMS support into 2.1.XXX 9 | * In 2.2 we are switching to modules and that will clean things up significantly 10 | * 11 | */ 12 | public class PlatformBuilder { 13 | private MinecraftGameVersion minecraftGameVersion; 14 | private ServerSoftwareType serverSoftwareType; 15 | 16 | public PlatformBuilder() { 17 | 18 | } 19 | 20 | public PlatformBuilder setMinecraftGameVersion(@NotNull MinecraftGameVersion minecraftGameVersion) { 21 | this.minecraftGameVersion = minecraftGameVersion; 22 | return this; 23 | } 24 | 25 | public PlatformBuilder setSoftwareType(@NotNull ServerSoftwareType softwareType) { 26 | this.serverSoftwareType = softwareType; 27 | return this; 28 | } 29 | 30 | public @Nullable Platform build() { 31 | return switch (serverSoftwareType) { 32 | case PAPER, SPIGOT, CRAFT_BUKKIT -> createBukkitPlatform(); 33 | default -> null; 34 | }; 35 | } 36 | 37 | private BukkitPlatform createBukkitPlatform() { 38 | return new BukkitPlatform(minecraftGameVersion); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/util/platform/ServerSoftwareType.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.util.platform; 2 | 3 | public enum ServerSoftwareType { 4 | PAPER, 5 | SPIGOT, 6 | CRAFT_BUKKIT, 7 | SPONGE, 8 | OTHER 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/util/platform/version/NumericVersioned.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.util.platform.version; 2 | 3 | public interface NumericVersioned extends Versioned { 4 | int asInt(); 5 | } 6 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/util/platform/version/SimpleNumericVersion.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.util.platform.version; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | 5 | public class SimpleNumericVersion extends SimpleVersion implements NumericVersioned { 6 | private final int versionNumber; 7 | 8 | public SimpleNumericVersion(int versionNumber) { 9 | super(String.valueOf(versionNumber)); 10 | this.versionNumber = versionNumber; 11 | } 12 | 13 | @Override 14 | public int asInt() { 15 | return versionNumber; 16 | } 17 | 18 | @Override 19 | public @NotNull String getVersionStr() { 20 | return super.getVersionString(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/util/platform/version/SimpleVersion.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.util.platform.version; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | 5 | public class SimpleVersion { 6 | @NotNull 7 | private final String versionString; 8 | 9 | public SimpleVersion(@NotNull String versionString) { 10 | this.versionString = versionString; 11 | } 12 | 13 | @NotNull 14 | public String getVersionString() { 15 | return versionString; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/util/platform/version/Versioned.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.util.platform.version; 2 | 3 | public interface Versioned { 4 | String getVersionStr(); 5 | } 6 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/util/random/InvalidStaticChance.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.util.random; 2 | 3 | public class InvalidStaticChance extends Exception { 4 | //Weeee 5 | } 6 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/util/random/SkillProbabilityType.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.util.random; 2 | 3 | public enum SkillProbabilityType { 4 | DYNAMIC_CONFIGURABLE, //Has multiple values used for calculation (taken from config files) 5 | STATIC_CONFIGURABLE, //A single value used for calculations (taken from config files) 6 | } 7 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/util/scoreboards/ObjectiveType.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.util.scoreboards; 2 | 3 | public enum ObjectiveType { 4 | SIDEBAR, 5 | POWER 6 | } 7 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/util/skills/SkillActivationType.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.util.skills; 2 | 3 | /** 4 | * Defines the type of random calculations to use with a given skill 5 | */ 6 | public enum SkillActivationType { 7 | //RANDOM_LINEAR_100_SCALE_NO_CAP, //A skill level of 100 would guarantee the proc with this 8 | RANDOM_LINEAR_100_SCALE_WITH_CAP, //This one is based on a scale of 1-100 but with a specified cap for max bonus 9 | RANDOM_STATIC_CHANCE, //The skill always has a SPECIFIC chance to succeed 10 | ALWAYS_FIRES //This skill isn't chance based and always fires 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/util/sounds/SoundType.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.util.sounds; 2 | 3 | public enum SoundType { 4 | ANVIL, 5 | LEVEL_UP, 6 | FIZZ, 7 | ITEM_BREAK, 8 | POP, 9 | CHIMAERA_WING, 10 | ROLL_ACTIVATED, 11 | SKILL_UNLOCKED, 12 | DEFLECT_ARROWS, 13 | TOOL_READY, 14 | ABILITY_ACTIVATED_GENERIC, 15 | ABILITY_ACTIVATED_BERSERK, 16 | BLEED, 17 | GLASS, 18 | ITEM_CONSUMED, 19 | CRIPPLE, 20 | TIRED; 21 | 22 | public boolean usesCustomPitch() { 23 | switch(this){ 24 | case POP: 25 | case FIZZ: 26 | return true; 27 | default: 28 | return false; 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/util/text/McMMOMessageType.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.util.text; 2 | 3 | import net.kyori.adventure.audience.Audience; 4 | import net.kyori.adventure.audience.MessageType; 5 | import net.kyori.adventure.identity.Identity; 6 | import net.kyori.adventure.text.Component; 7 | 8 | import java.util.function.BiConsumer; 9 | 10 | public enum McMMOMessageType { 11 | ACTION_BAR(Audience::sendActionBar), 12 | SYSTEM((audience, message) -> audience.sendMessage(Identity.nil(), message, MessageType.SYSTEM)); 13 | 14 | private final BiConsumer sender; 15 | 16 | McMMOMessageType(final BiConsumer sender) { 17 | this.sender = sender; 18 | } 19 | 20 | public void send(final Audience audience, final Component message) { 21 | this.sender.accept(audience, message); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/gmail/nossr50/worldguard/WorldGuardFlags.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.worldguard; 2 | 3 | import com.sk89q.worldguard.protection.flags.StateFlag; 4 | 5 | public class WorldGuardFlags { 6 | // StateFlag with the name "my-custom-flag", which defaults to "allow" 7 | public static final StateFlag MCMMO_ENABLE_WG_FLAG = new StateFlag("mcmmo", true); 8 | public static final StateFlag MCMMO_XP_WG_FLAG = new StateFlag("mcmmo-xp", true); 9 | public static final StateFlag MCMMO_HARDCORE_WG_FLAG = new StateFlag("mcmmo-hardcore", true); 10 | } 11 | -------------------------------------------------------------------------------- /src/main/resources/.jenkins: -------------------------------------------------------------------------------- 1 | ${JENKINS_KEY} -------------------------------------------------------------------------------- /src/main/resources/chat.yml: -------------------------------------------------------------------------------- 1 | # Settings for the chat channels in mcMMO 2 | Chat: 3 | # Turn this off if you don't want mcMMO to process any chat (such as party chat or admin chat) 4 | Enable: true 5 | Channels: 6 | Party: 7 | # Enable or disable party chat 8 | Enable: true 9 | # Whether to use the current display name of a player 10 | Use_Display_Names: true 11 | Send_To_Console: true 12 | Spies: 13 | # Whether players with the chat spy permission join the server with chat spying toggled on 14 | Automatically_Enable_Spying: false 15 | Admin: 16 | Send_To_Console: true 17 | # Enable or disable admin chat 18 | Enable: true 19 | # Whether to use the current display name of a player 20 | Use_Display_Names: true 21 | # CUSTOMIZATION INFORMATION 22 | # If you want to customize the look and feel of chat channels, that is handled through localization which is configurable 23 | # You can find information on how to handle that in the link below 24 | # https://mcmmo.org/wiki/Locale 25 | # When editing the locale for chat, do a search in the master text file (your local locale override file is empty at first, read the wiki article above) for "chat" and that should lead you right to the locale entries related to chat -------------------------------------------------------------------------------- /src/main/resources/coreskills.yml: -------------------------------------------------------------------------------- 1 | # 2 | # This file includes a few settings for each skill in mcMMO 3 | 4 | #Acrobatics 5 | Acrobatics: 6 | # turn this to false to disable all subskills for this skill 7 | Enabled: true 8 | Roll: 9 | Enabled: true -------------------------------------------------------------------------------- /src/main/resources/custom_item_support.yml: -------------------------------------------------------------------------------- 1 | # This is meant to be a general config for allowing mcMMO to allow interaction with custom items. 2 | # In the future, I would like to add configs to be specific about certain custom items. 3 | # For now, support is generalized to whether the custom item has a custom model. 4 | # This is an easy solution to implement for now, but not the most ideal. 5 | Custom_Item_Support: 6 | Repair: 7 | # Turn this off to disable repair on any items with custom model data 8 | Allow_Repair_On_Items_With_Custom_Model_Data: true 9 | Salvage: 10 | # Turn this off to disable salvage on any items with custom model data 11 | Allow_Salvage_On_Items_With_Custom_Model_Data: true 12 | -------------------------------------------------------------------------------- /src/main/resources/hidden.yml: -------------------------------------------------------------------------------- 1 | # 2 | # WARNING: THIS CONFIG IS FOR ADVANCED USERS ONLY. 3 | # You will need to reset any values in this config every time you update mcMMO 4 | ### 5 | Options: 6 | # true to use Chunklets metadata store system, false to disable 7 | Chunklets: true 8 | # Square root of the number of chunks to convert per tick. 9 | ConversionRate: 1 10 | # true to use enchantment buffs for Super Breaker & Giga Drill Breaker, false to use potion buffs 11 | EnchantmentBuffs: true -------------------------------------------------------------------------------- /src/main/resources/mods/blocks.default.yml: -------------------------------------------------------------------------------- 1 | # 2 | # Settings for Custom Excavation Blocks 3 | ### 4 | Excavation: 5 | Block_1|0: 6 | XP_Gain: 99 7 | Double_Drops_Enabled: true 8 | Block_2|0: 9 | XP_Gain: 99 10 | Double_Drops_Enabled: true 11 | 12 | # 13 | # Settings for Custom Herbalism Blocks 14 | ### 15 | Herbalism: 16 | Block_1|0: 17 | XP_Gain: 99 18 | Double_Drops_Enabled: true 19 | Block_2|0: 20 | XP_Gain: 99 21 | Double_Drops_Enabled: true 22 | 23 | # 24 | # Settings for Custom Mining Blocks 25 | ### 26 | Mining: 27 | Block_1|0: 28 | XP_Gain: 99 29 | Double_Drops_Enabled: true 30 | Is_Ore: true 31 | Smelting_XP_Gain: 9 32 | Block_2|0: 33 | XP_Gain: 99 34 | Double_Drops_Enabled: true 35 | Is_Ore: true 36 | Smelting_XP_Gain: 9 37 | 38 | # 39 | # Settings for Custom Woodcutting Blocks 40 | ### 41 | Woodcutting: 42 | Block_1|0: 43 | XP_Gain: 99 44 | Double_Drops_Enabled: true 45 | Is_Log: true 46 | Block_2|0: 47 | XP_Gain: 99 48 | Double_Drops_Enabled: true 49 | Is_Log: true 50 | 51 | # 52 | # Settings for Custom Ability Blocks 53 | # (These blocks don't trigger abilities) 54 | ### 55 | Ability_Blocks: 56 | Block_1|0: 57 | Block_2|0: -------------------------------------------------------------------------------- /src/main/resources/mods/entities.default.yml: -------------------------------------------------------------------------------- 1 | # 2 | # Settings for Custom Mobs 3 | # 4 | # Mob name should be the entity type of the mob - usually "ModName_EntityName" 5 | # Be sure to use the "_" character in place of any "." characters in the mob name. 6 | ### 7 | Mob_1: 8 | Class: CLASS_NAME 9 | XP_Multiplier: 1.0 10 | Tameable: false 11 | Taming_XP: 250 12 | CanBeSummoned: false 13 | COTW_Material: MATERIAL_NAME 14 | COTW_Material_Data: 9 15 | COTW_Material_Amount: 99 16 | Mob_2: 17 | Class: CLASS_NAME 18 | XP_Multiplier: 1.0 19 | Tameable: false 20 | Taming_XP: 250 21 | CanBeSummoned: false 22 | COTW_Material: MATERIAL_NAME 23 | COTW_Material_Data: 9 24 | COTW_Material_Amount: 99 25 | Mob_3: 26 | Class: CLASS_NAME 27 | XP_Multiplier: 1.0 28 | Tameable: false 29 | Taming_XP: 250 30 | CanBeSummoned: false 31 | COTW_Material: MATERIAL_NAME 32 | COTW_Material_Data: 9 33 | COTW_Material_Amount: 99 34 | Mob_4: 35 | Class: CLASS_NAME 36 | XP_Multiplier: 1.0 37 | Tameable: false 38 | Taming_XP: 250 39 | CanBeSummoned: false 40 | COTW_Material: MATERIAL_NAME 41 | COTW_Material_Data: 9 42 | COTW_Material_Amount: 99 43 | -------------------------------------------------------------------------------- /src/main/resources/party.yml: -------------------------------------------------------------------------------- 1 | # Settings for mcMMO Party System 2 | Party: 3 | # Enable or disable the mcMMO party system 4 | Enabled: true -------------------------------------------------------------------------------- /src/main/resources/upgrades_overhaul.yml: -------------------------------------------------------------------------------- 1 | # WARNING: DO NOT MODIFY THIS CONFIG 2 | Upgrades_Finished: 3 | ADD_FISHING: false 4 | ADD_BLAST_MINING_COOLDOWN: false 5 | ADD_SQL_INDEXES: false 6 | ADD_MOB_HEALTHBARS: false 7 | DROP_SQL_PARTY_NAMES: false 8 | DROP_SPOUT: false 9 | ADD_ALCHEMY: false 10 | FIX_SPELLING_NETHERITE_SALVAGE: false 11 | FIX_SPELLING_NETHERITE_REPAIR: false 12 | FIX_NETHERITE_SALVAGE_QUANTITIES: false 13 | ADD_UUIDS: false 14 | SQL_CHARSET_UTF8MB4: false 15 | -------------------------------------------------------------------------------- /src/test/java/com/gmail/nossr50/database/FlatFileDataProcessorTest.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.database; 2 | 3 | import org.junit.jupiter.api.Assertions; 4 | import org.junit.jupiter.api.Test; 5 | 6 | class FlatFileDataProcessorTest { 7 | 8 | @SuppressWarnings("ResultOfMethodCallIgnored") 9 | @Test 10 | void testGetExpectedValueType() { 11 | for (int i = 0; i < FlatFileDatabaseManager.DATA_ENTRY_COUNT; i++) { 12 | FlatFileDataProcessor.getExpectedValueType(i); 13 | } 14 | } 15 | 16 | @SuppressWarnings("ResultOfMethodCallIgnored") 17 | @Test 18 | void testGetExpectedValueTypeException() { 19 | Assertions.assertThrows(IndexOutOfBoundsException.class, () -> { 20 | for (int i = 0; i < FlatFileDatabaseManager.DATA_ENTRY_COUNT + 1; i++) { 21 | FlatFileDataProcessor.getExpectedValueType(i); 22 | } 23 | }); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/test/java/com/gmail/nossr50/database/flatfile/FlatFileDataUtilTest.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.database.flatfile; 2 | 3 | import com.gmail.nossr50.database.FlatFileDatabaseManager; 4 | import org.junit.jupiter.api.Assertions; 5 | import org.junit.jupiter.api.Test; 6 | 7 | import java.util.HashSet; 8 | 9 | class FlatFileDataUtilTest { 10 | 11 | @Test 12 | void getPreparedSaveDataLine() { 13 | 14 | } 15 | 16 | @Test 17 | void repairBadData() { 18 | 19 | } 20 | 21 | @Test 22 | void getZeroInitialisedData() { 23 | 24 | } 25 | 26 | @Test 27 | void testTooManyDataEntriesSplitString() { 28 | Assertions.assertThrows(AssertionError.class, () -> { 29 | FlatFileDataContainer dataContainer = new CategorizedFlatFileData(0, new HashSet<>(), new String[FlatFileDatabaseManager.DATA_ENTRY_COUNT + 1]); 30 | FlatFileDataUtil.getPreparedSaveDataLine(dataContainer); 31 | }); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/test/java/com/gmail/nossr50/datatypes/BlockLocationHistoryTest.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.datatypes; 2 | 3 | import org.bukkit.Location; 4 | import org.junit.jupiter.api.Assertions; 5 | import org.junit.jupiter.api.Test; 6 | 7 | class BlockLocationHistoryTest { 8 | @Test 9 | void testRemovesOldestElement() { 10 | BlockLocationHistory history = new BlockLocationHistory(2); 11 | Location locationA = new Location(null, 0, 1, 2); 12 | Location locationB = new Location(null, 1, 2, 3); 13 | Location locationC = new Location(null, 2, 3, 4); 14 | 15 | history.add(locationA); 16 | history.add(locationB); 17 | history.add(locationC); 18 | Assertions.assertFalse(history.contains(locationA)); 19 | Assertions.assertTrue(history.contains(locationB)); 20 | Assertions.assertTrue(history.contains(locationC)); 21 | } 22 | 23 | @Test 24 | void testSupportsDuplicateElement() { 25 | BlockLocationHistory history = new BlockLocationHistory(2); 26 | Location locationA = new Location(null, 0, 1, 2); 27 | Location locationB = new Location(null, 1, 2, 3); 28 | 29 | history.add(locationA); 30 | history.add(locationA); 31 | history.add(locationB); 32 | Assertions.assertTrue(history.contains(locationA)); 33 | Assertions.assertTrue(history.contains(locationB)); 34 | history.add(locationB); 35 | Assertions.assertFalse(history.contains(locationA)); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/test/java/com/gmail/nossr50/skills/tridents/TridentsTest.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.skills.tridents; 2 | 3 | import com.gmail.nossr50.MMOTestEnvironment; 4 | import com.gmail.nossr50.api.exceptions.InvalidSkillException; 5 | import org.bukkit.Material; 6 | import org.bukkit.entity.Player; 7 | import org.bukkit.inventory.ItemStack; 8 | import org.bukkit.inventory.PlayerInventory; 9 | import org.junit.jupiter.api.AfterEach; 10 | import org.junit.jupiter.api.BeforeEach; 11 | import org.mockito.Mockito; 12 | 13 | import java.util.logging.Logger; 14 | 15 | import static java.util.logging.Logger.getLogger; 16 | 17 | class TridentsTest extends MMOTestEnvironment { 18 | private static final Logger logger = getLogger(TridentsTest.class.getName()); 19 | 20 | TridentsManager tridentsManager; 21 | ItemStack trident; 22 | @BeforeEach 23 | void setUp() throws InvalidSkillException { 24 | mockBaseEnvironment(logger); 25 | 26 | // setup player and player related mocks after everything else 27 | this.player = Mockito.mock(Player.class); 28 | Mockito.when(player.getUniqueId()).thenReturn(playerUUID); 29 | 30 | // wire inventory 31 | this.playerInventory = Mockito.mock(PlayerInventory.class); 32 | this.trident = new ItemStack(Material.TRIDENT); 33 | Mockito.when(playerInventory.getItemInMainHand()).thenReturn(trident); 34 | 35 | // Set up spy for manager 36 | tridentsManager = Mockito.spy(new TridentsManager(mmoPlayer)); 37 | } 38 | 39 | @AfterEach 40 | void tearDown() { 41 | cleanUpStaticMocks(); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/test/java/com/gmail/nossr50/util/blockmeta/UnitTestObjectOutputStream.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.util.blockmeta; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | 5 | import java.io.IOException; 6 | import java.io.ObjectOutputStream; 7 | import java.io.OutputStream; 8 | 9 | class UnitTestObjectOutputStream extends ObjectOutputStream { 10 | 11 | public UnitTestObjectOutputStream(@NotNull OutputStream outputStream) throws IOException { 12 | super(outputStream); 13 | } 14 | 15 | @Override 16 | public void writeUTF(@NotNull String str) throws IOException { 17 | // Pretend to be the old class 18 | if (str.equals(LegacyChunkStore.class.getName())) 19 | str = "com.gmail.nossr50.util.blockmeta.chunkmeta.PrimitiveChunkStore"; 20 | super.writeUTF(str); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/test/java/com/gmail/nossr50/util/random/ProbabilityTestUtils.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.util.random; 2 | 3 | import static org.junit.jupiter.api.Assertions.assertEquals; 4 | 5 | public class ProbabilityTestUtils { 6 | public static void assertProbabilityExpectations(double expectedWinPercent, Probability probability) { 7 | double iterations = 2.0e7; //20 million 8 | double winCount = 0; 9 | for (int i = 0; i < iterations; i++) { 10 | if (probability.evaluate()) { 11 | winCount++; 12 | } 13 | } 14 | 15 | double successPercent = (winCount / iterations) * 100; 16 | System.out.println("Wins: " + winCount); 17 | System.out.println("Fails: " + (iterations - winCount)); 18 | System.out.println("Percentage succeeded: " + successPercent + ", Expected: " + expectedWinPercent); 19 | assertEquals(expectedWinPercent, successPercent, 0.035D); 20 | System.out.println("Variance is within tolerance levels!"); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/test/java/com/gmail/nossr50/util/text/TextUtilsTest.java: -------------------------------------------------------------------------------- 1 | package com.gmail.nossr50.util.text; 2 | 3 | import net.kyori.adventure.text.TextComponent; 4 | import net.kyori.adventure.text.format.NamedTextColor; 5 | import org.junit.jupiter.api.Assertions; 6 | import org.junit.jupiter.api.Test; 7 | 8 | /** 9 | * This Unit Test checks if Adventure was set up correctly and works as expected. 10 | * Normally, we can rely on this to be the case. However sometimes our dependencies 11 | * lack so far behind that things stop working correctly. 12 | * This test ensures that basic functionality is guaranteed to work as we would expect. 13 | * 14 | * See https://github.com/mcMMO-Dev/mcMMO/pull/4446 15 | * 16 | */ 17 | class TextUtilsTest { 18 | 19 | @Test 20 | void testColorizeText() { 21 | String inputText = "&4This text should be red."; 22 | 23 | /* 24 | * If this method raises an exception, we know Adventure is not set up correctly. 25 | * This will also make the test fail and warn us about it. 26 | */ 27 | TextComponent component = TextUtils.colorizeText(inputText); 28 | 29 | String message = "Looks like Adventure is not working correctly. We likely need to update our dependency!"; 30 | Assertions.assertEquals(NamedTextColor.DARK_RED, component.color(), message); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/test/resources/healthydb.users: -------------------------------------------------------------------------------- 1 | nossr50:1:IGNORED:IGNORED:10:2:20:3:4:5:6:7:8:9:10:30:40:50:60:70:80:90:100:IGNORED:11:110:111:222:333:444:555:666:777:IGNORED:12:120:888:IGNORED:HEARTS:13:130:588fe472-1c82-4c4e-9aa1-7eefccb277e3:1111:999:2020:140:14:150:15:1111:2222:3333:160:16:4444: 2 | mrfloris:2420:::0:2452:0:1983:1937:1790:3042:1138:3102:2408:3411:0:0:0:0:0:0:0:0::642:0:1617583171:0:1617165043:0:1617583004:1617563189:1616785408::2184:0:0:1617852413:HEARTS:415:0:631e3896-da2a-4077-974b-d047859d76bc:5:1600906906:3030:0:0:0:0:0:0:0:0:0:0: 3 | powerless:0:::0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0::0:0:0:0:0:0:0:0:0::0:0:0:1337:HEARTS:0:0:e0d07db8-f7e8-43c7-9ded-864dfc6f3b7c:5:1600906906:4040:0:0:0:0:0:0:0:0:0:0: -------------------------------------------------------------------------------- /src/test/resources/missinglastlogin.users: -------------------------------------------------------------------------------- 1 | # A single comment line is sometimes at the top of the DB 2 | nossr50:1:IGNORED:IGNORED:10:2:20:3:4:5:6:7:8:9:10:30:40:50:60:70:80:90:100:IGNORED:11:110:111:222:333:444:555:666:777:IGNORED:12:120:888:0:HEARTS:13:130:588fe472-1c82-4c4e-9aa1-7eefccb277e3:1111:999: 3 | mrfloris:2420:::0:2452:0:1983:1937:1790:3042:1138:3102:2408:3411:0:0:0:0:0:0:0:0::642:0:1617583171:0:1617165043:0:1617583004:1617563189:1616785408::2184:0:0:1617852413:HEARTS:415:0:631e3896-da2a-4077-974b-d047859d76bc:5:1600906906: 4 | powerless:0:::0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0::0:0:0:0:0:0:0:0:0::0:0:0:1337:HEARTS:0:0:e0d07db8-f7e8-43c7-9ded-864dfc6f3b7c:5:1600906906: -------------------------------------------------------------------------------- /src/test/resources/olderdb.users: -------------------------------------------------------------------------------- 1 | nossr50:1:IGNORED:IGNORED:10:2:20:3:4:5:6:7:8:9:10:30:40:50:60:70:80:90:100:IGNORED:11:110:111:222:333:444:555:666:777:IGNORED:12:120:888:IGNORED:HEARTS:13:130:588fe472-1c82-4c4e-9aa1-7eefccb277e3:1111:999:2020: 2 | mrfloris:2420:::0:2452:0:1983:1937:1790:3042:1138:3102:2408:3411:0:0:0:0:0:0:0:0::642:0:1617583171:0:1617165043:0:1617583004:1617563189:1616785408::2184:0:0:1617852413:HEARTS:415:0:631e3896-da2a-4077-974b-d047859d76bc:5:1600906906:3030: 3 | powerless:0:::0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0::0:0:0:0:0:0:0:0:0::0:0:0:1337:HEARTS:0:0:e0d07db8-f7e8-43c7-9ded-864dfc6f3b7c:5:1600906906:4040: --------------------------------------------------------------------------------