├── .github ├── ISSUE_TEMPLATE │ ├── 01-bug_report.yml │ └── config.yml └── workflows │ ├── build.yml │ ├── pr_comment.yml │ └── wiki.yml ├── .gitignore ├── 3rd_party_licenses ├── LICENSE-Apache_v2 ├── LICENSE-BDSv3 ├── LICENSE-GPLv2 ├── LICENSE-GPLv3 ├── LICENSE-MIT └── LICENSE-apache_math ├── LICENSE ├── NOTICE.md ├── README.md ├── build.gradle ├── buildSrc ├── build.gradle.kts └── src │ └── main │ └── java │ └── dev │ └── magicspells │ └── gradle │ ├── MSJavaPlugin.java │ └── MSPaperweight.java ├── core ├── build.gradle └── src │ └── main │ ├── antlr │ └── com │ │ └── nisovin │ │ └── magicspells │ │ └── util │ │ └── grammars │ │ ├── InputPredicate.g4 │ │ └── SpellFilter.g4 │ ├── java │ └── com │ │ └── nisovin │ │ └── magicspells │ │ ├── MagicLogger.java │ │ ├── MagicSpells.java │ │ ├── Perm.java │ │ ├── Spell.java │ │ ├── Spellbook.java │ │ ├── Subspell.java │ │ ├── castmodifiers │ │ ├── Condition.java │ │ ├── IModifier.java │ │ ├── Modifier.java │ │ ├── ModifierListener.java │ │ ├── ModifierSet.java │ │ ├── ModifierType.java │ │ ├── conditions │ │ │ ├── AbsorptionCondition.java │ │ │ ├── AdvancementCondition.java │ │ │ ├── AgeCondition.java │ │ │ ├── AliveCondition.java │ │ │ ├── AlwaysCondition.java │ │ │ ├── AngleCondition.java │ │ │ ├── AttributeBaseCondition.java │ │ │ ├── AttributeCondition.java │ │ │ ├── AttributeDefaultCondition.java │ │ │ ├── BiomeCondition.java │ │ │ ├── BlockTagCondition.java │ │ │ ├── BlockingCondition.java │ │ │ ├── BuffActiveCondition.java │ │ │ ├── BuildableCondition.java │ │ │ ├── BurnableCondition.java │ │ │ ├── CanPickupItemsCondition.java │ │ │ ├── CastCondition.java │ │ │ ├── ChanceCondition.java │ │ │ ├── ChestContainsCondition.java │ │ │ ├── ClientBrandNameCondition.java │ │ │ ├── ClimbingCondition.java │ │ │ ├── CollidableCondition.java │ │ │ ├── CustomNameCondition.java │ │ │ ├── CustomNameVisibleCondition.java │ │ │ ├── DataCondition.java │ │ │ ├── DayCondition.java │ │ │ ├── DisplayNameCondition.java │ │ │ ├── DistanceCondition.java │ │ │ ├── DurabilityCondition.java │ │ │ ├── ElevationCondition.java │ │ │ ├── EntityTypeCondition.java │ │ │ ├── EntityTypeTagCondition.java │ │ │ ├── FacingCondition.java │ │ │ ├── FallingCondition.java │ │ │ ├── FixedPoseCondition.java │ │ │ ├── FixedTimeCondition.java │ │ │ ├── FlyingCondition.java │ │ │ ├── FoodCondition.java │ │ │ ├── GameModeCondition.java │ │ │ ├── GlidingCondition.java │ │ │ ├── GriefPreventionIsOwnerCondition.java │ │ │ ├── HasItemAmountCondition.java │ │ │ ├── HasItemCondition.java │ │ │ ├── HasItemPreciseCondition.java │ │ │ ├── HasMarkCondition.java │ │ │ ├── HasScoreboardTagCondition.java │ │ │ ├── HasSpellCondition.java │ │ │ ├── HasTargetCondition.java │ │ │ ├── HealthCondition.java │ │ │ ├── HoldingCondition.java │ │ │ ├── HoldingPreciseCondition.java │ │ │ ├── HoveringWithCondition.java │ │ │ ├── InBlockCondition.java │ │ │ ├── InCuboidCondition.java │ │ │ ├── InNoMagicZoneCondition.java │ │ │ ├── InRegionCondition.java │ │ │ ├── InWorldCondition.java │ │ │ ├── InputCondition.java │ │ │ ├── IsNPCCondition.java │ │ │ ├── LastDamageTypeCondition.java │ │ │ ├── LastLifeCondition.java │ │ │ ├── LeapingCondition.java │ │ │ ├── LeashedCondition.java │ │ │ ├── LevelCondition.java │ │ │ ├── LightLevelCondition.java │ │ │ ├── LineOfSightCondition.java │ │ │ ├── LookingAtBlockCondition.java │ │ │ ├── LoopActiveCondition.java │ │ │ ├── MagicXpAboveCondition.java │ │ │ ├── MagicXpBelowCondition.java │ │ │ ├── ManaCondition.java │ │ │ ├── MaxManaCondition.java │ │ │ ├── MoneyCondition.java │ │ │ ├── MoonPhaseCondition.java │ │ │ ├── MultiCondition.java │ │ │ ├── NameCondition.java │ │ │ ├── NamePatternCondition.java │ │ │ ├── NightCondition.java │ │ │ ├── OffHandPreciseCondition.java │ │ │ ├── OffhandCondition.java │ │ │ ├── OnBlockCondition.java │ │ │ ├── OnCooldownCondition.java │ │ │ ├── OnFireCondition.java │ │ │ ├── OnGroundCondition.java │ │ │ ├── OnLeashCondition.java │ │ │ ├── OnSameTeamCondition.java │ │ │ ├── OnTeamCondition.java │ │ │ ├── OpenSlotsCondition.java │ │ │ ├── OutsideCondition.java │ │ │ ├── OverBlockCondition.java │ │ │ ├── OverGroundCondition.java │ │ │ ├── OwnedBuffActiveCondition.java │ │ │ ├── OwnedLoopActiveCondition.java │ │ │ ├── OxygenCondition.java │ │ │ ├── PassableCondition.java │ │ │ ├── PermissionCondition.java │ │ │ ├── PitchCondition.java │ │ │ ├── PlayerCountCondition.java │ │ │ ├── PlayerOnlineCondition.java │ │ │ ├── PluginEnabledCondition.java │ │ │ ├── PoseCondition.java │ │ │ ├── PotionEffectCondition.java │ │ │ ├── PowerCondition.java │ │ │ ├── PulserActiveCondition.java │ │ │ ├── RainingCondition.java │ │ │ ├── ReceivingRedstoneCondition.java │ │ │ ├── ReplaceableCondition.java │ │ │ ├── RicherThanCondition.java │ │ │ ├── RidingCondition.java │ │ │ ├── RiptidingCondition.java │ │ │ ├── RoofCondition.java │ │ │ ├── RotationCondition.java │ │ │ ├── SaturationCondition.java │ │ │ ├── SignTextCondition.java │ │ │ ├── SilentCondition.java │ │ │ ├── SleepingCondition.java │ │ │ ├── SlotSelectedCondition.java │ │ │ ├── SneakingCondition.java │ │ │ ├── SolidCondition.java │ │ │ ├── SpellBeneficialCondition.java │ │ │ ├── SpellCastStateCondition.java │ │ │ ├── SpellSelectedCondition.java │ │ │ ├── SpellTagCondition.java │ │ │ ├── SprintingCondition.java │ │ │ ├── StormCondition.java │ │ │ ├── SwimmingCondition.java │ │ │ ├── TargetMaxHealthCondition.java │ │ │ ├── TargetingCondition.java │ │ │ ├── TestForBlockCondition.java │ │ │ ├── ThunderingCondition.java │ │ │ ├── TimeCondition.java │ │ │ ├── TotemActiveCondition.java │ │ │ ├── UnderBlockCondition.java │ │ │ ├── UnderWaterCondition.java │ │ │ ├── UpTimeCondition.java │ │ │ ├── UsingItemCondition.java │ │ │ ├── VariableCondition.java │ │ │ ├── VariableMatchesCondition.java │ │ │ ├── VariableStringEqualsCondition.java │ │ │ ├── VelocityActiveCondition.java │ │ │ ├── WearingCondition.java │ │ │ ├── WearingInSlotCondition.java │ │ │ ├── WearingPreciseCondition.java │ │ │ ├── WorldGuardBooleanFlagCondition.java │ │ │ ├── WorldGuardRegionMembershipCondition.java │ │ │ ├── WorldGuardStateFlagCondition.java │ │ │ ├── YawCondition.java │ │ │ └── util │ │ │ │ ├── AbstractWorldGuardCondition.java │ │ │ │ └── OperatorCondition.java │ │ └── customdata │ │ │ ├── CustomData.java │ │ │ └── CustomDataFloat.java │ │ ├── commands │ │ ├── CommandHelpFilter.java │ │ ├── HelpPermission.java │ │ └── MagicCommand.java │ │ ├── events │ │ ├── BuffEndEvent.java │ │ ├── BuffStartEvent.java │ │ ├── ConditionsLoadingEvent.java │ │ ├── IMagicSpellsCompatEvent.java │ │ ├── MagicSpellsBlockBreakEvent.java │ │ ├── MagicSpellsBlockPlaceEvent.java │ │ ├── MagicSpellsEntityDamageByEntityEvent.java │ │ ├── MagicSpellsEntityRegainHealthEvent.java │ │ ├── MagicSpellsGenericPlayerEvent.java │ │ ├── MagicSpellsLoadedEvent.java │ │ ├── MagicSpellsLoadingEvent.java │ │ ├── MagicSpellsPlayerInteractEvent.java │ │ ├── ManaChangeEvent.java │ │ ├── ParticleProjectileHitEvent.java │ │ ├── PassiveListenersLoadingEvent.java │ │ ├── PortalEnterEvent.java │ │ ├── PortalEvent.java │ │ ├── PortalLeaveEvent.java │ │ ├── SpellApplyDamageEvent.java │ │ ├── SpellCastEvent.java │ │ ├── SpellCastedEvent.java │ │ ├── SpellEffectsLoadingEvent.java │ │ ├── SpellEvent.java │ │ ├── SpellForgetEvent.java │ │ ├── SpellLearnEvent.java │ │ ├── SpellPreImpactEvent.java │ │ ├── SpellSelectionChangeEvent.java │ │ ├── SpellSelectionChangedEvent.java │ │ ├── SpellTargetEvent.java │ │ ├── SpellTargetLocationEvent.java │ │ ├── SpellbookReloadEvent.java │ │ ├── TrackerMoveEvent.java │ │ └── VariablesLoadingEvent.java │ │ ├── exception │ │ └── MagicException.java │ │ ├── handlers │ │ ├── DebugHandler.java │ │ ├── DeprecationHandler.java │ │ ├── EnchantmentHandler.java │ │ ├── LifeLengthTracker.java │ │ ├── MagicXpHandler.java │ │ ├── MoneyHandler.java │ │ └── PotionEffectHandler.java │ │ ├── listeners │ │ ├── CastListener.java │ │ ├── ConsumeListener.java │ │ ├── DanceCastListener.java │ │ ├── LeftClickListener.java │ │ ├── MagicChatListener.java │ │ ├── MagicPlayerListener.java │ │ ├── MagicSpellListener.java │ │ ├── RightClickListener.java │ │ └── VariableListener.java │ │ ├── mana │ │ ├── ManaBar.java │ │ ├── ManaChangeReason.java │ │ ├── ManaHandler.java │ │ ├── ManaRank.java │ │ └── ManaSystem.java │ │ ├── spelleffects │ │ ├── EffectPosition.java │ │ ├── SpellEffect.java │ │ ├── effecttypes │ │ │ ├── ActionBarTextEffect.java │ │ │ ├── ArmorStandEffect.java │ │ │ ├── BlockBreakEffect.java │ │ │ ├── BossBarEffect.java │ │ │ ├── BroadcastEffect.java │ │ │ ├── CloudEffect.java │ │ │ ├── DragonDeathEffect.java │ │ │ ├── EffectLibEffect.java │ │ │ ├── EffectLibEntityEffect.java │ │ │ ├── EffectLibLineEffect.java │ │ │ ├── EnderSignalEffect.java │ │ │ ├── EntityEffect.java │ │ │ ├── ExplosionEffect.java │ │ │ ├── FireworksEffect.java │ │ │ ├── GameTestAddMarkerEffect.java │ │ │ ├── GameTestClearMarkersEffect.java │ │ │ ├── ItemCooldownEffect.java │ │ │ ├── ItemSprayEffect.java │ │ │ ├── LightningEffect.java │ │ │ ├── MobSpawnerEffect.java │ │ │ ├── NovaEffect.java │ │ │ ├── ParticleCloudEffect.java │ │ │ ├── ParticlesEffect.java │ │ │ ├── ParticlesPersonalEffect.java │ │ │ ├── PotionEffect.java │ │ │ ├── SmokeSwirlEffect.java │ │ │ ├── SmokeTrailEffect.java │ │ │ ├── SoundEffect.java │ │ │ ├── SoundPersonalEffect.java │ │ │ ├── SplashPotionEffect.java │ │ │ ├── SwingHandEffect.java │ │ │ ├── TitleEffect.java │ │ │ └── ToastEffect.java │ │ ├── trackers │ │ │ ├── AsyncEffectTracker.java │ │ │ ├── BuffEffectlibTracker.java │ │ │ ├── BuffTracker.java │ │ │ ├── EffectTracker.java │ │ │ ├── OrbitEffectlibTracker.java │ │ │ └── OrbitTracker.java │ │ └── util │ │ │ └── EffectlibSpellEffect.java │ │ ├── spells │ │ ├── BowSpell.java │ │ ├── BuffSpell.java │ │ ├── CommandSpell.java │ │ ├── DamageSpell.java │ │ ├── ExternalCommandSpell.java │ │ ├── InstantSpell.java │ │ ├── LocationSpell.java │ │ ├── MenuSpell.java │ │ ├── MultiSpell.java │ │ ├── OffhandCooldownSpell.java │ │ ├── PassiveSpell.java │ │ ├── PermissionSpell.java │ │ ├── PlayerMenuSpell.java │ │ ├── RandomSpell.java │ │ ├── TargetedEntityFromLocationSpell.java │ │ ├── TargetedEntitySpell.java │ │ ├── TargetedLocationSpell.java │ │ ├── TargetedMultiSpell.java │ │ ├── TargetedSpell.java │ │ ├── buff │ │ │ ├── ArmorSpell.java │ │ │ ├── CarpetSpell.java │ │ │ ├── ClaritySpell.java │ │ │ ├── DamageEmpowerSpell.java │ │ │ ├── DodgeSpell.java │ │ │ ├── DummySpell.java │ │ │ ├── EmpowerSpell.java │ │ │ ├── FlamewalkSpell.java │ │ │ ├── FrostwalkSpell.java │ │ │ ├── GillsSpell.java │ │ │ ├── HasteSpell.java │ │ │ ├── ImpactRecordSpell.java │ │ │ ├── InvisibilitySpell.java │ │ │ ├── InvulnerabilitySpell.java │ │ │ ├── LifewalkSpell.java │ │ │ ├── LightwalkSpell.java │ │ │ ├── LilywalkSpell.java │ │ │ ├── ManaRegenSpell.java │ │ │ ├── MinionSpell.java │ │ │ ├── ReachSpell.java │ │ │ ├── ReflectSpell.java │ │ │ ├── ResistSpell.java │ │ │ ├── SeeHealthSpell.java │ │ │ ├── SpellHasteSpell.java │ │ │ ├── StealthSpell.java │ │ │ ├── StonevisionSpell.java │ │ │ ├── WalkwaySpell.java │ │ │ ├── WaterwalkSpell.java │ │ │ ├── WindglideSpell.java │ │ │ ├── WindwalkSpell.java │ │ │ └── ext │ │ │ │ └── DisguiseSpell.java │ │ ├── command │ │ │ ├── AdminTeachSpell.java │ │ │ ├── BindSpell.java │ │ │ ├── ForgetSpell.java │ │ │ ├── HelpSpell.java │ │ │ ├── ImbueSpell.java │ │ │ ├── ItemSerializeSpell.java │ │ │ ├── KeybindSpell.java │ │ │ ├── ListSpell.java │ │ │ ├── ScrollSpell.java │ │ │ ├── SpellbookSpell.java │ │ │ ├── SublistSpell.java │ │ │ ├── TeachSpell.java │ │ │ ├── TomeSpell.java │ │ │ └── UnbindSpell.java │ │ ├── instant │ │ │ ├── BeamSpell.java │ │ │ ├── BlockBeamSpell.java │ │ │ ├── CastAtMarkSpell.java │ │ │ ├── ConfusionSpell.java │ │ │ ├── ConjureBookSpell.java │ │ │ ├── ConjureFireworkSpell.java │ │ │ ├── ConjureSpell.java │ │ │ ├── CraftSpell.java │ │ │ ├── DowseSpell.java │ │ │ ├── DummySpell.java │ │ │ ├── EnchantSpell.java │ │ │ ├── EnderchestSpell.java │ │ │ ├── FlightPathSpell.java │ │ │ ├── FoodSpell.java │ │ │ ├── ForcepushSpell.java │ │ │ ├── GateSpell.java │ │ │ ├── ItemProjectileSpell.java │ │ │ ├── LeapSpell.java │ │ │ ├── MagnetSpell.java │ │ │ ├── ManaSpell.java │ │ │ ├── MarkSpell.java │ │ │ ├── ParticleProjectileSpell.java │ │ │ ├── PhaseSpell.java │ │ │ ├── PortalSpell.java │ │ │ ├── ProjectileSpell.java │ │ │ ├── PurgeSpell.java │ │ │ ├── RecallSpell.java │ │ │ ├── RepairSpell.java │ │ │ ├── RitualSpell.java │ │ │ ├── RoarSpell.java │ │ │ ├── SteedSpell.java │ │ │ ├── ThrowBlockSpell.java │ │ │ ├── TimeSpell.java │ │ │ ├── UnconjureSpell.java │ │ │ ├── VariableCastSpell.java │ │ │ ├── VelocitySpell.java │ │ │ └── WallSpell.java │ │ ├── passive │ │ │ ├── AnvilListener.java │ │ │ ├── BlockBreakListener.java │ │ │ ├── BlockPlaceListener.java │ │ │ ├── BuffListener.java │ │ │ ├── CraftListener.java │ │ │ ├── DamageListener.java │ │ │ ├── DeathListener.java │ │ │ ├── DismountListener.java │ │ │ ├── DropItemListener.java │ │ │ ├── EnchantListener.java │ │ │ ├── EnterBedListener.java │ │ │ ├── EntityTargetListener.java │ │ │ ├── EquipListener.java │ │ │ ├── FatalDamageListener.java │ │ │ ├── FishListener.java │ │ │ ├── FoodLevelChangeListener.java │ │ │ ├── GameModeChangeListener.java │ │ │ ├── GiveDamageListener.java │ │ │ ├── GrindstoneListener.java │ │ │ ├── HitArrowListener.java │ │ │ ├── HotbarDeselectListener.java │ │ │ ├── HotbarSelectListener.java │ │ │ ├── InputListener.java │ │ │ ├── InsideBlockListener.java │ │ │ ├── InventoryActionListener.java │ │ │ ├── InventoryClickListener.java │ │ │ ├── InventoryCloseListener.java │ │ │ ├── InventoryOpenListener.java │ │ │ ├── JoinListener.java │ │ │ ├── JumpListener.java │ │ │ ├── KillListener.java │ │ │ ├── LeaveBedListener.java │ │ │ ├── LeftClickBlockCoordListener.java │ │ │ ├── LeftClickBlockTypeListener.java │ │ │ ├── LeftClickItemListener.java │ │ │ ├── MagicSpellsLoadedListener.java │ │ │ ├── ManaChangeListener.java │ │ │ ├── MissArrowListener.java │ │ │ ├── MountListener.java │ │ │ ├── OffhandSwapListener.java │ │ │ ├── PickupItemListener.java │ │ │ ├── PlayerAnimationListener.java │ │ │ ├── PlayerMoveListener.java │ │ │ ├── PlayerMoveToBlockListener.java │ │ │ ├── PortalEnterListener.java │ │ │ ├── PortalLeaveListener.java │ │ │ ├── PotionEffectListener.java │ │ │ ├── PrepareEnchantListener.java │ │ │ ├── QuitListener.java │ │ │ ├── RegainHealthListener.java │ │ │ ├── ResourcePackListener.java │ │ │ ├── RespawnListener.java │ │ │ ├── RightClickBlockCoordListener.java │ │ │ ├── RightClickBlockTypeListener.java │ │ │ ├── RightClickEntityListener.java │ │ │ ├── RightClickItemListener.java │ │ │ ├── SheepShearListener.java │ │ │ ├── ShootListener.java │ │ │ ├── SignBookListener.java │ │ │ ├── SmithListener.java │ │ │ ├── SpellCastListener.java │ │ │ ├── SpellCastedListener.java │ │ │ ├── SpellSelectListener.java │ │ │ ├── SpellTargetListener.java │ │ │ ├── SpellTargetedListener.java │ │ │ ├── StartFlyListener.java │ │ │ ├── StartGlideListener.java │ │ │ ├── StartPoseListener.java │ │ │ ├── StartSneakListener.java │ │ │ ├── StartSprintListener.java │ │ │ ├── StartSwimListener.java │ │ │ ├── StopFlyListener.java │ │ │ ├── StopGlideListener.java │ │ │ ├── StopPoseListener.java │ │ │ ├── StopSneakListener.java │ │ │ ├── StopSprintListener.java │ │ │ ├── StopSwimListener.java │ │ │ ├── TakeDamageListener.java │ │ │ ├── TeleportListener.java │ │ │ ├── TicksListener.java │ │ │ ├── UnequipListener.java │ │ │ ├── WorldChangeListener.java │ │ │ └── util │ │ │ │ └── PassiveListener.java │ │ └── targeted │ │ │ ├── AgeSpell.java │ │ │ ├── AreaEffectSpell.java │ │ │ ├── AreaScanSpell.java │ │ │ ├── BlinkSpell.java │ │ │ ├── BombSpell.java │ │ │ ├── BuildSpell.java │ │ │ ├── CaptureSpell.java │ │ │ ├── CarpetSpell.java │ │ │ ├── ChainSpell.java │ │ │ ├── CleanseSpell.java │ │ │ ├── CloseInventorySpell.java │ │ │ ├── CollisionSpell.java │ │ │ ├── CombustSpell.java │ │ │ ├── ConversationSpell.java │ │ │ ├── CreatureTargetSpell.java │ │ │ ├── CrippleSpell.java │ │ │ ├── CustomNameVisibilitySpell.java │ │ │ ├── DamageSpell.java │ │ │ ├── DataSpell.java │ │ │ ├── DestroySpell.java │ │ │ ├── DisarmSpell.java │ │ │ ├── DotSpell.java │ │ │ ├── DrainlifeSpell.java │ │ │ ├── DummySpell.java │ │ │ ├── EntityEditSpell.java │ │ │ ├── EntitySilenceSpell.java │ │ │ ├── EntombSpell.java │ │ │ ├── ExplodeSpell.java │ │ │ ├── FarmSpell.java │ │ │ ├── FireballSpell.java │ │ │ ├── FlySpell.java │ │ │ ├── ForcebombSpell.java │ │ │ ├── ForcetossSpell.java │ │ │ ├── GeyserSpell.java │ │ │ ├── GlideSpell.java │ │ │ ├── GlowSpell.java │ │ │ ├── GripSpell.java │ │ │ ├── HealSpell.java │ │ │ ├── HoldRightSpell.java │ │ │ ├── HomingMissileSpell.java │ │ │ ├── HomingProjectileSpell.java │ │ │ ├── LevitateSpell.java │ │ │ ├── LightningSpell.java │ │ │ ├── LoopSpell.java │ │ │ ├── MagicBondSpell.java │ │ │ ├── MaterializeSpell.java │ │ │ ├── MobGoalEditSpell.java │ │ │ ├── ModifyCooldownSpell.java │ │ │ ├── MountSpell.java │ │ │ ├── NovaSpell.java │ │ │ ├── OffsetLocationSpell.java │ │ │ ├── OrbitSpell.java │ │ │ ├── PainSpell.java │ │ │ ├── ParseSpell.java │ │ │ ├── ParticleCloudSpell.java │ │ │ ├── PasteSpell.java │ │ │ ├── PoseSpell.java │ │ │ ├── PotionEffectSpell.java │ │ │ ├── ProjectileModifySpell.java │ │ │ ├── PulserSpell.java │ │ │ ├── RegrowSpell.java │ │ │ ├── RemoveMarksSpell.java │ │ │ ├── ReplaceSpell.java │ │ │ ├── ResourcePackSpell.java │ │ │ ├── RewindSpell.java │ │ │ ├── RiptideSpell.java │ │ │ ├── RotateSpell.java │ │ │ ├── ScoreboardDataSpell.java │ │ │ ├── ShadowstepSpell.java │ │ │ ├── ShearSpell.java │ │ │ ├── SilenceSpell.java │ │ │ ├── SkinSpell.java │ │ │ ├── SlimeSizeSpell.java │ │ │ ├── SlotSelectSpell.java │ │ │ ├── SneakSpell.java │ │ │ ├── SpawnEntitySpell.java │ │ │ ├── SpawnTntSpell.java │ │ │ ├── SprintSpell.java │ │ │ ├── StructureSpell.java │ │ │ ├── StunSpell.java │ │ │ ├── SummonSpell.java │ │ │ ├── SwitchHealthSpell.java │ │ │ ├── SwitchSpell.java │ │ │ ├── TagEntitySpell.java │ │ │ ├── TelekinesisSpell.java │ │ │ ├── TeleportSpell.java │ │ │ ├── TotemSpell.java │ │ │ ├── TransmuteSpell.java │ │ │ ├── TreeSpell.java │ │ │ ├── VinesSpell.java │ │ │ ├── VolleySpell.java │ │ │ ├── ZapSpell.java │ │ │ ├── cleanse │ │ │ ├── BuffSpellCleanser.java │ │ │ ├── DotSpellCleanser.java │ │ │ ├── FireCleanser.java │ │ │ ├── FreezeCleanser.java │ │ │ ├── LevitateSpellCleanser.java │ │ │ ├── LoopSpellCleanser.java │ │ │ ├── OrbitSpellCleanser.java │ │ │ ├── PotionCleanser.java │ │ │ ├── SilenceSpellCleanser.java │ │ │ ├── StunSpellCleanser.java │ │ │ ├── TotemSpellCleanser.java │ │ │ └── util │ │ │ │ ├── Cleanser.java │ │ │ │ ├── CleanserManager.java │ │ │ │ ├── Cleansers.java │ │ │ │ └── SpellCleanser.java │ │ │ └── ext │ │ │ ├── GlowSpell.java │ │ │ └── PlaceholderAPIDataSpell.java │ │ ├── storage │ │ ├── Database.java │ │ ├── StorageHandler.java │ │ ├── databases │ │ │ ├── MySQLDatabase.java │ │ │ └── SQLiteDatabase.java │ │ └── types │ │ │ ├── DatabaseStorage.java │ │ │ └── TXTFileStorage.java │ │ ├── util │ │ ├── Angle.java │ │ ├── AttributeUtil.java │ │ ├── BlockPlatform.java │ │ ├── BlockUtils.java │ │ ├── BooleanUtils.java │ │ ├── BoundingBox.java │ │ ├── CastItem.java │ │ ├── CastResult.java │ │ ├── ColorUtil.java │ │ ├── ConfigReaderUtil.java │ │ ├── DelayableEntity.java │ │ ├── DependsOn.java │ │ ├── DeprecationNotice.java │ │ ├── EntityData.java │ │ ├── InputPredicate.java │ │ ├── IntMap.java │ │ ├── InventoryUtil.java │ │ ├── ItemUtil.java │ │ ├── LocationUtil.java │ │ ├── MagicConfig.java │ │ ├── MagicConversationPrefix.java │ │ ├── MobUtil.java │ │ ├── ModifierResult.java │ │ ├── Name.java │ │ ├── OverridePriority.java │ │ ├── ParticleUtil.java │ │ ├── RegexUtil.java │ │ ├── SpellAnimation.java │ │ ├── SpellData.java │ │ ├── SpellFilter.java │ │ ├── SpellReagents.java │ │ ├── SpellUtil.java │ │ ├── TargetBooleanState.java │ │ ├── TargetInfo.java │ │ ├── TemporaryBlockSet.java │ │ ├── TimeUtil.java │ │ ├── TxtUtil.java │ │ ├── Util.java │ │ ├── ValidTargetChecker.java │ │ ├── ValidTargetList.java │ │ ├── VariableMod.java │ │ ├── ai │ │ │ ├── CustomGoal.java │ │ │ ├── CustomGoals.java │ │ │ ├── CustomGoalsManager.java │ │ │ └── goals │ │ │ │ ├── LookAtEntityTypeGoal.java │ │ │ │ └── PathToGoal.java │ │ ├── bounds │ │ │ ├── Space.java │ │ │ └── SpaceCombined.java │ │ ├── compat │ │ │ ├── CompatBasics.java │ │ │ ├── DummyExemptionAssistant.java │ │ │ ├── EventUtil.java │ │ │ ├── ExemptionAssistant.java │ │ │ └── nocheatplus │ │ │ │ └── NoCheatPlusExemptionAid.java │ │ ├── config │ │ │ ├── ConfigData.java │ │ │ ├── ConfigDataUtil.java │ │ │ ├── CustomFunctions.java │ │ │ ├── FunctionData.java │ │ │ ├── StringData.java │ │ │ └── VariableConfigData.java │ │ ├── data │ │ │ ├── DataEntity.java │ │ │ └── DataLivingEntity.java │ │ ├── glow │ │ │ └── impl │ │ │ │ └── PacketEventsGlowManager.java │ │ ├── grammars │ │ │ ├── AndPredicate.java │ │ │ ├── GrammarUtils.java │ │ │ ├── InputPredicateVisitorImpl.java │ │ │ ├── OrPredicate.java │ │ │ ├── SpellFilterVisitorImpl.java │ │ │ └── XorPredicate.java │ │ ├── itemreader │ │ │ ├── AttributeHandler.java │ │ │ ├── BannerHandler.java │ │ │ ├── BlockDataHandler.java │ │ │ ├── CustomModelDataHandler.java │ │ │ ├── DurabilityHandler.java │ │ │ ├── FireworkEffectHandler.java │ │ │ ├── FireworkHandler.java │ │ │ ├── LeatherArmorHandler.java │ │ │ ├── LoreHandler.java │ │ │ ├── NameHandler.java │ │ │ ├── PotionHandler.java │ │ │ ├── RepairableHandler.java │ │ │ ├── SkullHandler.java │ │ │ ├── SuspiciousStewHandler.java │ │ │ ├── WrittenBookHandler.java │ │ │ └── alternative │ │ │ │ ├── AlternativeReaderManager.java │ │ │ │ ├── ItemConfigTransformer.java │ │ │ │ ├── SpigotReader.java │ │ │ │ └── VanillaReader.java │ │ ├── magicitems │ │ │ ├── MagicItem.java │ │ │ ├── MagicItemData.java │ │ │ ├── MagicItemDataParser.java │ │ │ └── MagicItems.java │ │ ├── managers │ │ │ ├── BossBarManager.java │ │ │ ├── BuffManager.java │ │ │ ├── ConditionManager.java │ │ │ ├── ExperienceBarManager.java │ │ │ ├── PassiveManager.java │ │ │ ├── SpellEffectManager.java │ │ │ └── VariableManager.java │ │ ├── messagelistener │ │ │ ├── MagicConversation.java │ │ │ ├── MessageListener.java │ │ │ ├── MessageListenerFactory.java │ │ │ └── listeners │ │ │ │ ├── ConversationBlocker.java │ │ │ │ └── ProtocolLibListener.java │ │ ├── projectile │ │ │ ├── ProjectileManager.java │ │ │ ├── ProjectileManagerArrow.java │ │ │ ├── ProjectileManagerDragonFireball.java │ │ │ ├── ProjectileManagerEgg.java │ │ │ ├── ProjectileManagerEnderPearl.java │ │ │ ├── ProjectileManagerFireball.java │ │ │ ├── ProjectileManagerFishHook.java │ │ │ ├── ProjectileManagerLargeFireball.java │ │ │ ├── ProjectileManagerLingeringPotion.java │ │ │ ├── ProjectileManagerLlamaSpit.java │ │ │ ├── ProjectileManagerShulkerBullet.java │ │ │ ├── ProjectileManagerSmallFireball.java │ │ │ ├── ProjectileManagerSnowball.java │ │ │ ├── ProjectileManagerSpectralArrow.java │ │ │ ├── ProjectileManagerSplashPotion.java │ │ │ ├── ProjectileManagerThrownExpBottle.java │ │ │ ├── ProjectileManagerThrownPotion.java │ │ │ ├── ProjectileManagerTrident.java │ │ │ ├── ProjectileManagerWitherSkull.java │ │ │ └── ProjectileManagers.java │ │ ├── prompt │ │ │ ├── MagicEnumSetPrompt.java │ │ │ ├── MagicFixedSetPrompt.java │ │ │ ├── MagicPromptResponder.java │ │ │ ├── MagicRegexPrompt.java │ │ │ └── PromptType.java │ │ ├── recipes │ │ │ ├── CustomRecipe.java │ │ │ ├── CustomRecipeType.java │ │ │ ├── CustomRecipes.java │ │ │ └── types │ │ │ │ ├── CustomBlastingRecipe.java │ │ │ │ ├── CustomCampfireRecipe.java │ │ │ │ ├── CustomCookingRecipe.java │ │ │ │ ├── CustomFurnaceRecipe.java │ │ │ │ ├── CustomShapedRecipe.java │ │ │ │ ├── CustomShapelessRecipe.java │ │ │ │ ├── CustomSmithingRecipe.java │ │ │ │ ├── CustomSmokingRecipe.java │ │ │ │ └── CustomStonecuttingRecipe.java │ │ └── trackers │ │ │ ├── Interaction.java │ │ │ ├── ItemProjectileTracker.java │ │ │ ├── ParticleProjectileTracker.java │ │ │ ├── ProjectileTracker.java │ │ │ └── Tracker.java │ │ ├── variables │ │ ├── Variable.java │ │ ├── meta │ │ │ ├── AbsorptionVariable.java │ │ │ ├── AltitudeVariable.java │ │ │ ├── AttackCooldownVariable.java │ │ │ ├── AttributeBaseValueVariable.java │ │ │ ├── AttributeVariable.java │ │ │ ├── BedCoordXVariable.java │ │ │ ├── BedCoordYVariable.java │ │ │ ├── BedCoordZVariable.java │ │ │ ├── BodyYawVariable.java │ │ │ ├── CompassTargetXVariable.java │ │ │ ├── CompassTargetYVariable.java │ │ │ ├── CompassTargetZVariable.java │ │ │ ├── CoordPitchVariable.java │ │ │ ├── CoordXVariable.java │ │ │ ├── CoordYVariable.java │ │ │ ├── CoordYawVariable.java │ │ │ ├── CoordZVariable.java │ │ │ ├── CurrentHealthVariable.java │ │ │ ├── CurrentTickVariable.java │ │ │ ├── EntityIDVariable.java │ │ │ ├── ExhaustionVariable.java │ │ │ ├── ExperienceLevelVariable.java │ │ │ ├── ExperienceVariable.java │ │ │ ├── FallDistanceVariable.java │ │ │ ├── FireTicksVariable.java │ │ │ ├── FlySpeedVariable.java │ │ │ ├── FoodLevelVariable.java │ │ │ ├── ForwardsMovementVariable.java │ │ │ ├── FreezeTicksVariable.java │ │ │ ├── HealthScaleVariable.java │ │ │ ├── LastDamageVariable.java │ │ │ ├── ManaRegenVariable.java │ │ │ ├── ManaVariable.java │ │ │ ├── MaxFireTicksVariable.java │ │ │ ├── MaxFreezeTicksVariable.java │ │ │ ├── MaxHealthVariable.java │ │ │ ├── MaxManaVariable.java │ │ │ ├── MaximumAirVariable.java │ │ │ ├── MaximumNoDamageTicksVariable.java │ │ │ ├── NoDamageTicksVariable.java │ │ │ ├── PlayersOnlineVariable.java │ │ │ ├── RemainingAirVariable.java │ │ │ ├── RespawnCoordXVariable.java │ │ │ ├── RespawnCoordYVariable.java │ │ │ ├── RespawnCoordZVariable.java │ │ │ ├── SaturatedRegenRateVariable.java │ │ │ ├── SaturationVariable.java │ │ │ ├── SidewaysMovementVariable.java │ │ │ ├── SleepTicksVariable.java │ │ │ ├── StarvationRateVariable.java │ │ │ ├── TimestampDaysVariable.java │ │ │ ├── TimestampHoursVariable.java │ │ │ ├── TimestampMillisecondsVariable.java │ │ │ ├── TimestampMinutesVariable.java │ │ │ ├── TimestampSecondsVariable.java │ │ │ ├── UnsaturatedRegenRateVariable.java │ │ │ ├── VelocityXVariable.java │ │ │ ├── VelocityYVariable.java │ │ │ ├── VelocityZVariable.java │ │ │ └── WalkSpeedVariable.java │ │ └── variabletypes │ │ │ ├── DistanceToLocationVariable.java │ │ │ ├── GlobalStringVariable.java │ │ │ ├── GlobalVariable.java │ │ │ ├── MetaVariable.java │ │ │ ├── PlayerStringVariable.java │ │ │ ├── PlayerVariable.java │ │ │ └── SquaredDistanceToLocationVariable.java │ │ ├── volatilecode │ │ ├── ManagerVolatile.java │ │ └── VolatileCodeDisabled.java │ │ └── zones │ │ ├── NoMagicZone.java │ │ ├── NoMagicZoneCuboid.java │ │ ├── NoMagicZoneManager.java │ │ └── NoMagicZoneWorldGuard.java │ └── resources │ ├── defaults.yml │ ├── general.yml │ ├── mana.yml │ ├── plugin.yml │ ├── spells-command.yml │ ├── spells-regular.yml │ └── zones.yml ├── factions ├── build.gradle └── src │ └── main │ ├── java │ └── com │ │ └── nisovin │ │ └── magicspells │ │ └── factions │ │ ├── FactionsConditions.java │ │ ├── MagicSpellsFactions.java │ │ └── conditions │ │ ├── HasFactionCondition.java │ │ ├── PowerEqualsCondition.java │ │ ├── PowerGreaterThanCondition.java │ │ └── PowerLessThanCondition.java │ └── resources │ └── plugin.yml ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── jitpack.yml ├── memory ├── build.gradle └── src │ └── main │ ├── java │ └── com │ │ └── nisovin │ │ └── magicspells │ │ └── memory │ │ ├── MagicSpellsMemory.java │ │ └── MemorySpellListener.java │ └── resources │ ├── config.yml │ └── plugin.yml ├── nms ├── latest │ ├── build.gradle │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── nisovin │ │ └── magicspells │ │ └── volatilecode │ │ └── latest │ │ ├── VolatileCodeLatest.java │ │ └── VolatileGlowManagerLatest.java ├── shared │ ├── build.gradle │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── nisovin │ │ └── magicspells │ │ ├── util │ │ └── glow │ │ │ ├── GlowManager.java │ │ │ ├── LibsDisguiseHelper.java │ │ │ └── PacketBasedGlowManager.java │ │ └── volatilecode │ │ ├── VolatileCodeHandle.java │ │ └── VolatileCodeHelper.java └── v1_21_4 │ ├── build.gradle │ └── src │ └── main │ └── java │ └── com │ └── nisovin │ └── magicspells │ └── volatilecode │ └── v1_21_4 │ ├── VolatileCode_v1_21_4.java │ └── VolatileGlowManager_v1_21_4.java ├── settings.gradle.kts ├── shop ├── build.gradle └── src │ └── main │ ├── java │ └── com │ │ └── nisovin │ │ └── magicspells │ │ └── shop │ │ ├── CurrencyHandler.java │ │ ├── MagicSpellsShop.java │ │ └── Perm.java │ └── resources │ ├── config.yml │ └── plugin.yml ├── teams ├── build.gradle └── src │ └── main │ ├── java │ └── com │ │ └── nisovin │ │ └── magicspells │ │ └── teams │ │ ├── CreateTeamSubCommand.java │ │ ├── ListTeamsSubCommand.java │ │ ├── MagicSpellsTeams.java │ │ ├── MagicSpellsTeamsCommand.java │ │ ├── Team.java │ │ ├── TeamInfoSubCommand.java │ │ └── TeamsSubCommand.java │ └── resources │ ├── config.yml │ └── plugin.yml └── towny ├── build.gradle └── src └── main ├── java └── com │ └── nisovin │ └── magicspells │ └── towny │ └── MagicSpellsTowny.java └── resources ├── config.yml └── plugin.yml /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | contact_links: 3 | - name: Discord server 4 | url: https://discord.magicspells.dev 5 | about: Please visit our Discord server for questions and support. 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.class 2 | *.iml 3 | .classpath 4 | .project 5 | .settings/org.eclipse.jdt.core.prefs 6 | .idea/ 7 | Build/ 8 | .gradle/ 9 | -------------------------------------------------------------------------------- /3rd_party_licenses/LICENSE-MIT: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) [yyyy] [name of copyright owner] 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("dev.magicspells.msjava") 3 | id("io.papermc.paperweight.userdev") version "2.0.0-beta.17" apply false 4 | } 5 | 6 | subprojects { 7 | apply plugin: "dev.magicspells.msjava" 8 | 9 | dependencies { 10 | implementation(group: "io.papermc.paper", name: "paper-api", version: "1.21.4-R0.1-SNAPSHOT") 11 | } 12 | 13 | processResources { 14 | expand(["version": version]) 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /buildSrc/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | `java-gradle-plugin` 3 | } 4 | 5 | repositories { 6 | mavenCentral() 7 | } 8 | 9 | java { 10 | toolchain { 11 | languageVersion.set(JavaLanguageVersion.of(21)) 12 | } 13 | } 14 | 15 | gradlePlugin { 16 | plugins { 17 | create("msjava") { 18 | id = "dev.magicspells.msjava" 19 | implementationClass = "dev.magicspells.gradle.MSJavaPlugin" 20 | } 21 | create("mspaperweight") { 22 | id = "dev.magicspells.mspaperweight" 23 | implementationClass = "dev.magicspells.gradle.MSPaperweight" 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /buildSrc/src/main/java/dev/magicspells/gradle/MSPaperweight.java: -------------------------------------------------------------------------------- 1 | package dev.magicspells.gradle; 2 | 3 | import org.gradle.api.Plugin; 4 | import org.gradle.api.Project; 5 | 6 | public class MSPaperweight implements Plugin { 7 | // TODO figure out how to apply the plugin 8 | @Override 9 | public void apply(Project project) { 10 | project.getDependencies().add("paperweightDevelopmentBundle", "io.papermc.paper:dev-bundle:1.21.4-R0.1-SNAPSHOT").because("We need a server implementation rather than just an api here."); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /core/src/main/antlr/com/nisovin/magicspells/util/grammars/InputPredicate.g4: -------------------------------------------------------------------------------- 1 | grammar InputPredicate; 2 | 3 | options { 4 | language = Java; 5 | caseInsensitive = true; 6 | } 7 | 8 | parse: expr=expression EOF; 9 | 10 | expression 11 | : '(' expr=expression ')' # parenthesis 12 | | '!' expr=expression # not 13 | | left=expression '&' right=expression # and 14 | | left=expression '^' right=expression # xor 15 | | left=expression '|' right=expression # or 16 | | input=input_label # input 17 | ; 18 | 19 | input_label: token=(FORWARD | BACKWARD | LEFT | RIGHT | JUMP | SNEAK | SPRINT); 20 | 21 | WHITESPACE: [\p{White_Space}]+ -> skip; 22 | 23 | FORWARD: 'forward'; 24 | BACKWARD: 'backward'; 25 | LEFT: 'left'; 26 | RIGHT: 'right'; 27 | JUMP: 'jump'; 28 | SNEAK: 'sneak'; 29 | SPRINT: 'sprint'; 30 | -------------------------------------------------------------------------------- /core/src/main/antlr/com/nisovin/magicspells/util/grammars/SpellFilter.g4: -------------------------------------------------------------------------------- 1 | grammar SpellFilter; 2 | 3 | options { 4 | language = Java; 5 | } 6 | 7 | parse: expr=expression EOF; 8 | 9 | expression 10 | : '(' expr=expression ')' # parenthesis 11 | | '!' expr=expression # not 12 | | left=expression '&' right=expression # and 13 | | left=expression '^' right=expression # xor 14 | | left=expression '|' right=expression # or 15 | | '#' tag=IDENTIFIER # tag 16 | | spell=IDENTIFIER # spell 17 | ; 18 | 19 | WHITESPACE: [\p{White_Space}]+ -> skip; 20 | IDENTIFIER: ~[#\p{White_Space}&|^!()] ~[\p{White_Space}&|^!()]*; 21 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/castmodifiers/Condition.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.castmodifiers; 2 | 3 | import org.bukkit.Location; 4 | import org.bukkit.entity.LivingEntity; 5 | 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | import com.nisovin.magicspells.util.Name; 9 | import com.nisovin.magicspells.util.DependsOn; 10 | 11 | /** 12 | * Annotations: 13 | * 17 | */ 18 | public abstract class Condition { 19 | 20 | public abstract boolean initialize(@NotNull String var); 21 | 22 | public abstract boolean check(LivingEntity livingEntity); 23 | 24 | public abstract boolean check(LivingEntity livingEntity, LivingEntity target); 25 | 26 | public abstract boolean check(LivingEntity livingEntity, Location location); 27 | 28 | } 29 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/castmodifiers/conditions/AlwaysCondition.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.castmodifiers.conditions; 2 | 3 | import org.bukkit.Location; 4 | import org.bukkit.entity.LivingEntity; 5 | 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | import com.nisovin.magicspells.util.Name; 9 | import com.nisovin.magicspells.castmodifiers.Condition; 10 | 11 | @Name("always") 12 | public class AlwaysCondition extends Condition { 13 | 14 | @Override 15 | public boolean initialize(@NotNull String var) { 16 | return true; 17 | } 18 | 19 | @Override 20 | public boolean check(LivingEntity caster) { 21 | return true; 22 | } 23 | 24 | @Override 25 | public boolean check(LivingEntity caster, LivingEntity target) { 26 | return true; 27 | } 28 | 29 | @Override 30 | public boolean check(LivingEntity caster, Location location) { 31 | return true; 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/castmodifiers/conditions/BlockingCondition.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.castmodifiers.conditions; 2 | 3 | import org.bukkit.Location; 4 | import org.bukkit.entity.Player; 5 | import org.bukkit.entity.LivingEntity; 6 | 7 | import org.jetbrains.annotations.NotNull; 8 | 9 | import com.nisovin.magicspells.util.Name; 10 | import com.nisovin.magicspells.castmodifiers.Condition; 11 | 12 | @Name("blocking") 13 | public class BlockingCondition extends Condition { 14 | 15 | @Override 16 | public boolean initialize(@NotNull String var) { 17 | return true; 18 | } 19 | 20 | @Override 21 | public boolean check(LivingEntity caster) { 22 | return blocking(caster); 23 | } 24 | 25 | @Override 26 | public boolean check(LivingEntity caster, LivingEntity target) { 27 | return blocking(target); 28 | } 29 | 30 | @Override 31 | public boolean check(LivingEntity caster, Location location) { 32 | return false; 33 | } 34 | 35 | private boolean blocking(LivingEntity target) { 36 | if (!(target instanceof Player pl)) return false; 37 | return pl.isBlocking(); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/castmodifiers/conditions/BuildableCondition.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.castmodifiers.conditions; 2 | 3 | import org.bukkit.Location; 4 | import org.bukkit.entity.LivingEntity; 5 | 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | import com.nisovin.magicspells.util.Name; 9 | import com.nisovin.magicspells.castmodifiers.Condition; 10 | 11 | @Name("buildable") 12 | public class BuildableCondition extends Condition { 13 | 14 | @Override 15 | public boolean initialize(@NotNull String var) { 16 | return true; 17 | } 18 | 19 | @Override 20 | public boolean check(LivingEntity livingEntity) { 21 | return false; 22 | } 23 | 24 | @Override 25 | public boolean check(LivingEntity livingEntity, LivingEntity target) { 26 | return false; 27 | } 28 | 29 | @Override 30 | public boolean check(LivingEntity livingEntity, Location location) { 31 | return location.getBlock().isBuildable(); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/castmodifiers/conditions/BurnableCondition.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.castmodifiers.conditions; 2 | 3 | import org.bukkit.Location; 4 | import org.bukkit.entity.LivingEntity; 5 | 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | import com.nisovin.magicspells.util.Name; 9 | import com.nisovin.magicspells.castmodifiers.Condition; 10 | 11 | @Name("burnable") 12 | public class BurnableCondition extends Condition { 13 | 14 | @Override 15 | public boolean initialize(@NotNull String var) { 16 | return true; 17 | } 18 | 19 | @Override 20 | public boolean check(LivingEntity livingEntity) { 21 | return false; 22 | } 23 | 24 | @Override 25 | public boolean check(LivingEntity livingEntity, LivingEntity target) { 26 | return false; 27 | } 28 | 29 | @Override 30 | public boolean check(LivingEntity livingEntity, Location location) { 31 | return location.getBlock().isBurnable(); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/castmodifiers/conditions/CanPickupItemsCondition.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.castmodifiers.conditions; 2 | 3 | import org.bukkit.Location; 4 | import org.bukkit.entity.LivingEntity; 5 | 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | import com.nisovin.magicspells.util.Name; 9 | import com.nisovin.magicspells.castmodifiers.Condition; 10 | 11 | @Name("canpickupitems") 12 | public class CanPickupItemsCondition extends Condition { 13 | 14 | @Override 15 | public boolean initialize(@NotNull String var) { 16 | return true; 17 | } 18 | 19 | @Override 20 | public boolean check(LivingEntity caster) { 21 | return canPickup(caster); 22 | } 23 | 24 | @Override 25 | public boolean check(LivingEntity caster, LivingEntity target) { 26 | return canPickup(target); 27 | } 28 | 29 | @Override 30 | public boolean check(LivingEntity caster, Location location) { 31 | return false; 32 | } 33 | 34 | private boolean canPickup(LivingEntity target) { 35 | return target.getCanPickupItems(); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/castmodifiers/conditions/ClimbingCondition.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.castmodifiers.conditions; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | 5 | import org.bukkit.Location; 6 | import org.bukkit.entity.LivingEntity; 7 | 8 | import com.nisovin.magicspells.util.Name; 9 | import com.nisovin.magicspells.castmodifiers.Condition; 10 | 11 | @Name("climbing") 12 | public class ClimbingCondition extends Condition { 13 | 14 | @Override 15 | public boolean initialize(@NotNull String var) { 16 | return true; 17 | } 18 | 19 | @Override 20 | public boolean check(LivingEntity caster) { 21 | return caster.isClimbing(); 22 | } 23 | 24 | @Override 25 | public boolean check(LivingEntity caster, LivingEntity target) { 26 | return target.isClimbing(); 27 | } 28 | 29 | @Override 30 | public boolean check(LivingEntity caster, Location location) { 31 | return false; 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/castmodifiers/conditions/CollidableCondition.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.castmodifiers.conditions; 2 | 3 | import org.bukkit.Location; 4 | import org.bukkit.entity.LivingEntity; 5 | 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | import com.nisovin.magicspells.util.Name; 9 | import com.nisovin.magicspells.castmodifiers.Condition; 10 | 11 | @Name("collidable") 12 | public class CollidableCondition extends Condition { 13 | 14 | @Override 15 | public boolean initialize(@NotNull String var) { 16 | return true; 17 | } 18 | 19 | @Override 20 | public boolean check(LivingEntity livingEntity) { 21 | return false; 22 | } 23 | 24 | @Override 25 | public boolean check(LivingEntity livingEntity, LivingEntity target) { 26 | return false; 27 | } 28 | 29 | @Override 30 | public boolean check(LivingEntity livingEntity, Location location) { 31 | return location.getBlock().isCollidable(); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/castmodifiers/conditions/CustomNameVisibleCondition.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.castmodifiers.conditions; 2 | 3 | import org.bukkit.Location; 4 | import org.bukkit.entity.LivingEntity; 5 | 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | import com.nisovin.magicspells.util.Name; 9 | import com.nisovin.magicspells.castmodifiers.Condition; 10 | 11 | @Name("customnamevisible") 12 | public class CustomNameVisibleCondition extends Condition { 13 | 14 | @Override 15 | public boolean initialize(@NotNull String var) { 16 | return true; 17 | } 18 | 19 | @Override 20 | public boolean check(LivingEntity caster) { 21 | return nameVisible(caster); 22 | } 23 | 24 | @Override 25 | public boolean check(LivingEntity caster, LivingEntity target) { 26 | return nameVisible(target); 27 | } 28 | 29 | @Override 30 | public boolean check(LivingEntity caster, Location location) { 31 | return false; 32 | } 33 | 34 | private boolean nameVisible(LivingEntity target) { 35 | return target.isCustomNameVisible(); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/castmodifiers/conditions/DayCondition.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.castmodifiers.conditions; 2 | 3 | import org.bukkit.Location; 4 | import org.bukkit.entity.LivingEntity; 5 | 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | import com.nisovin.magicspells.util.Name; 9 | import com.nisovin.magicspells.castmodifiers.Condition; 10 | 11 | @Name("day") 12 | public class DayCondition extends Condition { 13 | 14 | @Override 15 | public boolean initialize(@NotNull String var) { 16 | return true; 17 | } 18 | 19 | @Override 20 | public boolean check(LivingEntity caster) { 21 | return caster.getWorld().isDayTime(); 22 | } 23 | 24 | @Override 25 | public boolean check(LivingEntity caster, LivingEntity target) { 26 | return target.getWorld().isDayTime(); 27 | } 28 | 29 | @Override 30 | public boolean check(LivingEntity caster, Location location) { 31 | return location.getWorld().isDayTime(); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/castmodifiers/conditions/FallingCondition.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.castmodifiers.conditions; 2 | 3 | import org.bukkit.Location; 4 | import org.bukkit.entity.LivingEntity; 5 | 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | import com.nisovin.magicspells.util.Name; 9 | import com.nisovin.magicspells.castmodifiers.Condition; 10 | 11 | @Name("falling") 12 | public class FallingCondition extends Condition { 13 | 14 | @Override 15 | public boolean initialize(@NotNull String var) { 16 | return true; 17 | } 18 | 19 | @Override 20 | public boolean check(LivingEntity caster) { 21 | return isFalling(caster); 22 | } 23 | 24 | @Override 25 | public boolean check(LivingEntity caster, LivingEntity target) { 26 | return isFalling(target); 27 | } 28 | 29 | @Override 30 | public boolean check(LivingEntity caster, Location location) { 31 | return false; 32 | } 33 | 34 | private boolean isFalling(LivingEntity target) { 35 | return target.getFallDistance() > 0; 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/castmodifiers/conditions/FixedPoseCondition.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.castmodifiers.conditions; 2 | 3 | import org.bukkit.Location; 4 | import org.bukkit.entity.LivingEntity; 5 | 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | import com.nisovin.magicspells.util.Name; 9 | import com.nisovin.magicspells.castmodifiers.Condition; 10 | 11 | @Name("fixedpose") 12 | public class FixedPoseCondition extends Condition { 13 | 14 | @Override 15 | public boolean initialize(@NotNull String var) { 16 | return var.isEmpty(); 17 | } 18 | 19 | @Override 20 | public boolean check(LivingEntity caster) { 21 | return caster.hasFixedPose(); 22 | } 23 | 24 | @Override 25 | public boolean check(LivingEntity caster, LivingEntity target) { 26 | return target.hasFixedPose(); 27 | } 28 | 29 | @Override 30 | public boolean check(LivingEntity caster, Location location) { 31 | return false; 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/castmodifiers/conditions/FixedTimeCondition.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.castmodifiers.conditions; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | 5 | import org.bukkit.Location; 6 | import org.bukkit.entity.LivingEntity; 7 | 8 | import com.nisovin.magicspells.util.Name; 9 | import com.nisovin.magicspells.castmodifiers.Condition; 10 | 11 | @Name("fixedtime") 12 | public class FixedTimeCondition extends Condition { 13 | 14 | @Override 15 | public boolean initialize(@NotNull String var) { 16 | return true; 17 | } 18 | 19 | @Override 20 | public boolean check(LivingEntity caster) { 21 | return caster.getWorld().isFixedTime(); 22 | } 23 | 24 | @Override 25 | public boolean check(LivingEntity caster, LivingEntity target) { 26 | return target.getWorld().isFixedTime(); 27 | } 28 | 29 | @Override 30 | public boolean check(LivingEntity caster, Location location) { 31 | return location.getWorld().isFixedTime(); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/castmodifiers/conditions/FlyingCondition.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.castmodifiers.conditions; 2 | 3 | import org.bukkit.Location; 4 | import org.bukkit.entity.Player; 5 | import org.bukkit.entity.LivingEntity; 6 | 7 | import org.jetbrains.annotations.NotNull; 8 | 9 | import com.nisovin.magicspells.util.Name; 10 | import com.nisovin.magicspells.castmodifiers.Condition; 11 | 12 | @Name("flying") 13 | public class FlyingCondition extends Condition { 14 | 15 | @Override 16 | public boolean initialize(@NotNull String var) { 17 | return true; 18 | } 19 | 20 | @Override 21 | public boolean check(LivingEntity caster) { 22 | return isFlying(caster); 23 | } 24 | 25 | @Override 26 | public boolean check(LivingEntity caster, LivingEntity target) { 27 | return isFlying(target); 28 | } 29 | 30 | @Override 31 | public boolean check(LivingEntity caster, Location location) { 32 | return false; 33 | } 34 | 35 | private boolean isFlying(LivingEntity target) { 36 | return target instanceof Player pl && pl.isFlying(); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/castmodifiers/conditions/GlidingCondition.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.castmodifiers.conditions; 2 | 3 | import org.bukkit.Location; 4 | import org.bukkit.entity.LivingEntity; 5 | 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | import com.nisovin.magicspells.util.Name; 9 | import com.nisovin.magicspells.castmodifiers.Condition; 10 | 11 | @Name("gliding") 12 | public class GlidingCondition extends Condition { 13 | 14 | @Override 15 | public boolean initialize(@NotNull String var) { 16 | return true; 17 | } 18 | 19 | @Override 20 | public boolean check(LivingEntity caster) { 21 | return isGliding(caster); 22 | } 23 | 24 | @Override 25 | public boolean check(LivingEntity caster, LivingEntity target) { 26 | return isGliding(target); 27 | } 28 | 29 | @Override 30 | public boolean check(LivingEntity caster, Location location) { 31 | return false; 32 | } 33 | 34 | private boolean isGliding(LivingEntity target) { 35 | return target.isGliding(); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/castmodifiers/conditions/IsNPCCondition.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.castmodifiers.conditions; 2 | 3 | import org.bukkit.Location; 4 | import org.bukkit.entity.LivingEntity; 5 | 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | import com.nisovin.magicspells.util.Name; 9 | import com.nisovin.magicspells.castmodifiers.Condition; 10 | 11 | @Name("isnpc") 12 | public class IsNPCCondition extends Condition { 13 | 14 | @Override 15 | public boolean initialize(@NotNull String var) { 16 | return true; 17 | } 18 | 19 | @Override 20 | public boolean check(LivingEntity caster) { 21 | return isNPC(caster); 22 | } 23 | 24 | @Override 25 | public boolean check(LivingEntity caster, LivingEntity target) { 26 | return isNPC(target); 27 | } 28 | 29 | @Override 30 | public boolean check(LivingEntity caster, Location location) { 31 | return false; 32 | } 33 | 34 | private boolean isNPC(LivingEntity target) { 35 | return target.hasMetadata("NPC"); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/castmodifiers/conditions/LeashedCondition.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.castmodifiers.conditions; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | 5 | import org.bukkit.Location; 6 | import org.bukkit.entity.LivingEntity; 7 | 8 | import com.nisovin.magicspells.util.Name; 9 | import com.nisovin.magicspells.castmodifiers.Condition; 10 | 11 | @Name("leashed") 12 | public class LeashedCondition extends Condition { 13 | 14 | @Override 15 | public boolean initialize(@NotNull String var) { 16 | return true; 17 | } 18 | 19 | @Override 20 | public boolean check(LivingEntity caster) { 21 | return caster.isLeashed(); 22 | } 23 | 24 | @Override 25 | public boolean check(LivingEntity caster, LivingEntity target) { 26 | return target.isLeashed(); 27 | } 28 | 29 | @Override 30 | public boolean check(LivingEntity caster, Location location) { 31 | return false; 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/castmodifiers/conditions/LineOfSightCondition.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.castmodifiers.conditions; 2 | 3 | import org.bukkit.Location; 4 | import org.bukkit.entity.LivingEntity; 5 | 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | import com.nisovin.magicspells.util.Name; 9 | import com.nisovin.magicspells.castmodifiers.Condition; 10 | 11 | @Name("los") 12 | public class LineOfSightCondition extends Condition { 13 | 14 | @Override 15 | public boolean initialize(@NotNull String var) { 16 | return true; 17 | } 18 | 19 | @Override 20 | public boolean check(LivingEntity caster) { 21 | return false; 22 | } 23 | 24 | @Override 25 | public boolean check(LivingEntity caster, LivingEntity target) { 26 | return caster.hasLineOfSight(target); 27 | } 28 | 29 | @Override 30 | public boolean check(LivingEntity caster, Location location) { 31 | return caster.hasLineOfSight(location); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/castmodifiers/conditions/NightCondition.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.castmodifiers.conditions; 2 | 3 | import org.bukkit.World; 4 | import org.bukkit.Location; 5 | import org.bukkit.entity.LivingEntity; 6 | 7 | import org.jetbrains.annotations.NotNull; 8 | 9 | import com.nisovin.magicspells.util.Name; 10 | import com.nisovin.magicspells.castmodifiers.Condition; 11 | 12 | @Name("night") 13 | public class NightCondition extends Condition { 14 | 15 | @Override 16 | public boolean initialize(@NotNull String var) { 17 | return true; 18 | } 19 | 20 | @Override 21 | public boolean check(LivingEntity caster) { 22 | return night(caster.getWorld()); 23 | } 24 | 25 | @Override 26 | public boolean check(LivingEntity caster, LivingEntity target) { 27 | return night(target.getWorld()); 28 | } 29 | 30 | @Override 31 | public boolean check(LivingEntity caster, Location location) { 32 | return night(location.getWorld()); 33 | } 34 | 35 | private boolean night(World world) { 36 | return !world.isFixedTime() && !world.isDayTime(); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/castmodifiers/conditions/OnGroundCondition.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.castmodifiers.conditions; 2 | 3 | import org.bukkit.Location; 4 | import org.bukkit.entity.LivingEntity; 5 | 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | import com.nisovin.magicspells.util.Name; 9 | import com.nisovin.magicspells.castmodifiers.Condition; 10 | 11 | @Name("onground") 12 | public class OnGroundCondition extends Condition { 13 | 14 | @Override 15 | public boolean initialize(@NotNull String var) { 16 | return true; 17 | } 18 | 19 | @Override 20 | public boolean check(LivingEntity caster) { 21 | return onGround(caster); 22 | } 23 | 24 | @Override 25 | public boolean check(LivingEntity caster, LivingEntity target) { 26 | return onGround(target); 27 | } 28 | 29 | @Override 30 | public boolean check(LivingEntity caster, Location location) { 31 | return false; 32 | } 33 | 34 | private boolean onGround(LivingEntity target) { 35 | return target.isOnGround(); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/castmodifiers/conditions/OnLeashCondition.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.castmodifiers.conditions; 2 | 3 | import org.bukkit.Location; 4 | import org.bukkit.entity.LivingEntity; 5 | 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | import com.nisovin.magicspells.util.Name; 9 | import com.nisovin.magicspells.castmodifiers.Condition; 10 | 11 | @Name("onleash") 12 | public class OnLeashCondition extends Condition { 13 | 14 | @Override 15 | public boolean initialize(@NotNull String var) { 16 | return true; 17 | } 18 | 19 | @Override 20 | public boolean check(LivingEntity caster) { 21 | return isLeashed(caster); 22 | } 23 | 24 | @Override 25 | public boolean check(LivingEntity caster, LivingEntity target) { 26 | return isLeashed(target); 27 | } 28 | 29 | @Override 30 | public boolean check(LivingEntity caster, Location location) { 31 | return false; 32 | } 33 | 34 | private boolean isLeashed(LivingEntity target) { 35 | return target.isLeashed(); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/castmodifiers/conditions/OwnedLoopActiveCondition.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.castmodifiers.conditions; 2 | 3 | import java.util.Collection; 4 | 5 | import org.bukkit.entity.LivingEntity; 6 | 7 | import com.nisovin.magicspells.util.Name; 8 | import com.nisovin.magicspells.spells.targeted.LoopSpell.Loop; 9 | 10 | @Name("ownedloopactive") 11 | public class OwnedLoopActiveCondition extends LoopActiveCondition { 12 | 13 | @Override 14 | public boolean check(LivingEntity caster) { 15 | return check(caster, caster); 16 | } 17 | 18 | @Override 19 | public boolean check(LivingEntity caster, LivingEntity target) { 20 | int count = 0; 21 | 22 | Collection loops = loop.getActiveLoops().get(target.getUniqueId()); 23 | for (Loop loop : loops) 24 | if (caster.equals(loop.getCaster())) 25 | count++; 26 | 27 | return compare(count, value); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/castmodifiers/conditions/PassableCondition.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.castmodifiers.conditions; 2 | 3 | import org.bukkit.Location; 4 | import org.bukkit.entity.LivingEntity; 5 | 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | import com.nisovin.magicspells.util.Name; 9 | import com.nisovin.magicspells.castmodifiers.Condition; 10 | 11 | @Name("passable") 12 | public class PassableCondition extends Condition { 13 | 14 | @Override 15 | public boolean initialize(@NotNull String var) { 16 | return true; 17 | } 18 | 19 | @Override 20 | public boolean check(LivingEntity livingEntity) { 21 | return false; 22 | } 23 | 24 | @Override 25 | public boolean check(LivingEntity livingEntity, LivingEntity target) { 26 | return false; 27 | } 28 | 29 | @Override 30 | public boolean check(LivingEntity livingEntity, Location location) { 31 | return location.getBlock().isPassable(); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/castmodifiers/conditions/PermissionCondition.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.castmodifiers.conditions; 2 | 3 | import org.bukkit.Location; 4 | import org.bukkit.entity.LivingEntity; 5 | 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | import com.nisovin.magicspells.util.Name; 9 | import com.nisovin.magicspells.castmodifiers.Condition; 10 | 11 | @Name("permission") 12 | public class PermissionCondition extends Condition { 13 | 14 | private String perm; 15 | 16 | @Override 17 | public boolean initialize(@NotNull String var) { 18 | perm = var; 19 | return true; 20 | } 21 | 22 | @Override 23 | public boolean check(LivingEntity caster) { 24 | return hasPermission(caster); 25 | } 26 | 27 | @Override 28 | public boolean check(LivingEntity caster, LivingEntity target) { 29 | return hasPermission(target); 30 | } 31 | 32 | @Override 33 | public boolean check(LivingEntity caster, Location location) { 34 | return false; 35 | } 36 | 37 | private boolean hasPermission(LivingEntity target) { 38 | return target.hasPermission(perm); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/castmodifiers/conditions/PlayerOnlineCondition.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.castmodifiers.conditions; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.Location; 5 | import org.bukkit.entity.LivingEntity; 6 | 7 | import org.jetbrains.annotations.NotNull; 8 | 9 | import com.nisovin.magicspells.util.Name; 10 | import com.nisovin.magicspells.castmodifiers.Condition; 11 | 12 | @Name("playeronline") 13 | public class PlayerOnlineCondition extends Condition { 14 | 15 | private String name; 16 | 17 | @Override 18 | public boolean initialize(@NotNull String var) { 19 | name = var; 20 | return true; 21 | } 22 | 23 | @Override 24 | public boolean check(LivingEntity caster) { 25 | return isOnline(); 26 | } 27 | 28 | @Override 29 | public boolean check(LivingEntity caster, LivingEntity target) { 30 | return isOnline(); 31 | } 32 | 33 | @Override 34 | public boolean check(LivingEntity caster, Location location) { 35 | return isOnline(); 36 | } 37 | 38 | private boolean isOnline() { 39 | return Bukkit.getPlayerExact(name) != null; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/castmodifiers/conditions/RainingCondition.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.castmodifiers.conditions; 2 | 3 | import org.bukkit.Location; 4 | import org.bukkit.entity.LivingEntity; 5 | 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | import com.nisovin.magicspells.util.Name; 9 | import com.nisovin.magicspells.castmodifiers.Condition; 10 | 11 | @Name("raining") 12 | public class RainingCondition extends Condition { 13 | 14 | @Override 15 | public boolean initialize(@NotNull String var) { 16 | return true; 17 | } 18 | 19 | @Override 20 | public boolean check(LivingEntity caster) { 21 | return isRaining(caster.getLocation()); 22 | } 23 | 24 | @Override 25 | public boolean check(LivingEntity caster, LivingEntity target) { 26 | return isRaining(target.getLocation()); 27 | } 28 | 29 | @Override 30 | public boolean check(LivingEntity caster, Location location) { 31 | return isRaining(location); 32 | } 33 | 34 | private boolean isRaining(Location location) { 35 | return location.getWorld().hasStorm(); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/castmodifiers/conditions/ReplaceableCondition.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.castmodifiers.conditions; 2 | 3 | import org.bukkit.Location; 4 | import org.bukkit.entity.LivingEntity; 5 | 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | import com.nisovin.magicspells.util.Name; 9 | import com.nisovin.magicspells.castmodifiers.Condition; 10 | 11 | @Name("replaceable") 12 | public class ReplaceableCondition extends Condition { 13 | 14 | @Override 15 | public boolean initialize(@NotNull String var) { 16 | return true; 17 | } 18 | 19 | @Override 20 | public boolean check(LivingEntity livingEntity) { 21 | return false; 22 | } 23 | 24 | @Override 25 | public boolean check(LivingEntity livingEntity, LivingEntity target) { 26 | return false; 27 | } 28 | 29 | @Override 30 | public boolean check(LivingEntity livingEntity, Location location) { 31 | return location.getBlock().isReplaceable(); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/castmodifiers/conditions/RiptidingCondition.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.castmodifiers.conditions; 2 | 3 | import org.bukkit.Location; 4 | import org.bukkit.entity.LivingEntity; 5 | 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | import com.nisovin.magicspells.util.Name; 9 | import com.nisovin.magicspells.castmodifiers.Condition; 10 | 11 | @Name("riptiding") 12 | public class RiptidingCondition extends Condition { 13 | 14 | @Override 15 | public boolean initialize(@NotNull String var) { 16 | return true; 17 | } 18 | 19 | @Override 20 | public boolean check(LivingEntity caster) { 21 | return isRiptiding(caster); 22 | } 23 | 24 | @Override 25 | public boolean check(LivingEntity caster, LivingEntity target) { 26 | return isRiptiding(target); 27 | } 28 | 29 | @Override 30 | public boolean check(LivingEntity caster, Location location) { 31 | return false; 32 | } 33 | 34 | private boolean isRiptiding(LivingEntity target) { 35 | return target.isRiptiding(); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/castmodifiers/conditions/SilentCondition.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.castmodifiers.conditions; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | 5 | import org.bukkit.Location; 6 | import org.bukkit.entity.LivingEntity; 7 | 8 | import com.nisovin.magicspells.util.Name; 9 | import com.nisovin.magicspells.castmodifiers.Condition; 10 | 11 | @Name("silent") 12 | public class SilentCondition extends Condition { 13 | 14 | @Override 15 | public boolean initialize(@NotNull String var) { 16 | return var.isEmpty(); 17 | } 18 | 19 | @Override 20 | public boolean check(LivingEntity caster) { 21 | return caster.isSilent(); 22 | } 23 | 24 | @Override 25 | public boolean check(LivingEntity caster, LivingEntity target) { 26 | return target.isSilent(); 27 | } 28 | 29 | @Override 30 | public boolean check(LivingEntity caster, Location location) { 31 | return false; 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/castmodifiers/conditions/SleepingCondition.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.castmodifiers.conditions; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | 5 | import org.bukkit.Location; 6 | import org.bukkit.entity.LivingEntity; 7 | 8 | import com.nisovin.magicspells.util.Name; 9 | import com.nisovin.magicspells.castmodifiers.Condition; 10 | 11 | @Name("sleeping") 12 | public class SleepingCondition extends Condition { 13 | 14 | @Override 15 | public boolean initialize(@NotNull String var) { 16 | return true; 17 | } 18 | 19 | @Override 20 | public boolean check(LivingEntity caster) { 21 | return caster.isSleeping(); 22 | } 23 | 24 | @Override 25 | public boolean check(LivingEntity caster, LivingEntity target) { 26 | return target.isSleeping(); 27 | } 28 | 29 | @Override 30 | public boolean check(LivingEntity caster, Location location) { 31 | return false; 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/castmodifiers/conditions/SneakingCondition.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.castmodifiers.conditions; 2 | 3 | import org.bukkit.Location; 4 | import org.bukkit.entity.LivingEntity; 5 | 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | import com.nisovin.magicspells.util.Name; 9 | import com.nisovin.magicspells.castmodifiers.Condition; 10 | 11 | @Name("sneaking") 12 | public class SneakingCondition extends Condition { 13 | 14 | @Override 15 | public boolean initialize(@NotNull String var) { 16 | return true; 17 | } 18 | 19 | @Override 20 | public boolean check(LivingEntity caster) { 21 | return isSneaking(caster); 22 | } 23 | 24 | @Override 25 | public boolean check(LivingEntity caster, LivingEntity target) { 26 | return isSneaking(target); 27 | } 28 | 29 | @Override 30 | public boolean check(LivingEntity caster, Location location) { 31 | return false; 32 | } 33 | 34 | private boolean isSneaking(LivingEntity target) { 35 | return target.isSneaking(); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/castmodifiers/conditions/SolidCondition.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.castmodifiers.conditions; 2 | 3 | import org.bukkit.Location; 4 | import org.bukkit.entity.LivingEntity; 5 | 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | import com.nisovin.magicspells.util.Name; 9 | import com.nisovin.magicspells.castmodifiers.Condition; 10 | 11 | @Name("solid") 12 | public class SolidCondition extends Condition { 13 | 14 | @Override 15 | public boolean initialize(@NotNull String var) { 16 | return true; 17 | } 18 | 19 | @Override 20 | public boolean check(LivingEntity livingEntity) { 21 | return false; 22 | } 23 | 24 | @Override 25 | public boolean check(LivingEntity livingEntity, LivingEntity target) { 26 | return false; 27 | } 28 | 29 | @Override 30 | public boolean check(LivingEntity livingEntity, Location location) { 31 | return location.getBlock().isSolid(); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/castmodifiers/conditions/SprintingCondition.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.castmodifiers.conditions; 2 | 3 | import org.bukkit.Location; 4 | import org.bukkit.entity.Player; 5 | import org.bukkit.entity.LivingEntity; 6 | 7 | import org.jetbrains.annotations.NotNull; 8 | 9 | import com.nisovin.magicspells.util.Name; 10 | import com.nisovin.magicspells.castmodifiers.Condition; 11 | 12 | @Name("sprinting") 13 | public class SprintingCondition extends Condition { 14 | 15 | @Override 16 | public boolean initialize(@NotNull String var) { 17 | return true; 18 | } 19 | 20 | @Override 21 | public boolean check(LivingEntity caster) { 22 | return isSprinting(caster); 23 | } 24 | 25 | @Override 26 | public boolean check(LivingEntity caster, LivingEntity target) { 27 | return isSprinting(target); 28 | } 29 | 30 | @Override 31 | public boolean check(LivingEntity caster, Location location) { 32 | return false; 33 | } 34 | 35 | private boolean isSprinting(LivingEntity target) { 36 | if (!(target instanceof Player pl)) return false; 37 | return pl.isSprinting(); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/castmodifiers/conditions/StormCondition.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.castmodifiers.conditions; 2 | 3 | import org.bukkit.Location; 4 | import org.bukkit.entity.LivingEntity; 5 | 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | import com.nisovin.magicspells.util.Name; 9 | import com.nisovin.magicspells.castmodifiers.Condition; 10 | 11 | @Name("storm") 12 | public class StormCondition extends Condition { 13 | 14 | @Override 15 | public boolean initialize(@NotNull String var) { 16 | return true; 17 | } 18 | 19 | @Override 20 | public boolean check(LivingEntity caster) { 21 | return stormy(caster.getLocation()); 22 | } 23 | 24 | @Override 25 | public boolean check(LivingEntity caster, LivingEntity target) { 26 | return stormy(target.getLocation()); 27 | } 28 | 29 | @Override 30 | public boolean check(LivingEntity caster, Location location) { 31 | return stormy(location); 32 | } 33 | 34 | private boolean stormy(Location location) { 35 | return location.getWorld().hasStorm() || location.getWorld().isThundering(); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/castmodifiers/conditions/SwimmingCondition.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.castmodifiers.conditions; 2 | 3 | import org.bukkit.Location; 4 | import org.bukkit.entity.LivingEntity; 5 | 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | import com.nisovin.magicspells.util.Name; 9 | import com.nisovin.magicspells.castmodifiers.Condition; 10 | 11 | @Name("swimming") 12 | public class SwimmingCondition extends Condition { 13 | 14 | @Override 15 | public boolean initialize(@NotNull String var) { 16 | return true; 17 | } 18 | 19 | @Override 20 | public boolean check(LivingEntity caster) { 21 | return isSwimming(caster); 22 | } 23 | 24 | @Override 25 | public boolean check(LivingEntity caster, LivingEntity target) { 26 | return isSwimming(target); 27 | } 28 | 29 | @Override 30 | public boolean check(LivingEntity caster, Location location) { 31 | return false; 32 | } 33 | 34 | private boolean isSwimming(LivingEntity target) { 35 | return target.isSwimming(); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/castmodifiers/conditions/ThunderingCondition.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.castmodifiers.conditions; 2 | 3 | import org.bukkit.Location; 4 | import org.bukkit.entity.LivingEntity; 5 | 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | import com.nisovin.magicspells.util.Name; 9 | import com.nisovin.magicspells.castmodifiers.Condition; 10 | 11 | @Name("thundering") 12 | public class ThunderingCondition extends Condition { 13 | 14 | @Override 15 | public boolean initialize(@NotNull String var) { 16 | return true; 17 | } 18 | 19 | @Override 20 | public boolean check(LivingEntity caster) { 21 | return thundering(caster.getLocation()); 22 | } 23 | 24 | @Override 25 | public boolean check(LivingEntity caster, LivingEntity target) { 26 | return thundering(target.getLocation()); 27 | } 28 | 29 | @Override 30 | public boolean check(LivingEntity caster, Location location) { 31 | return thundering(location); 32 | } 33 | 34 | private boolean thundering(Location location) { 35 | return location.getWorld().isThundering(); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/castmodifiers/conditions/UnderWaterCondition.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.castmodifiers.conditions; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | 5 | import org.bukkit.Location; 6 | import org.bukkit.entity.LivingEntity; 7 | 8 | import com.nisovin.magicspells.util.Name; 9 | import com.nisovin.magicspells.castmodifiers.Condition; 10 | 11 | @Name("underwater") 12 | public class UnderWaterCondition extends Condition { 13 | 14 | @Override 15 | public boolean initialize(@NotNull String var) { 16 | return true; 17 | } 18 | 19 | @Override 20 | public boolean check(LivingEntity caster) { 21 | return caster.isUnderWater(); 22 | } 23 | 24 | @Override 25 | public boolean check(LivingEntity caster, LivingEntity target) { 26 | return target.isUnderWater(); 27 | } 28 | 29 | @Override 30 | public boolean check(LivingEntity caster, Location location) { 31 | return false; 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/castmodifiers/conditions/util/OperatorCondition.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.castmodifiers.conditions.util; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | 5 | import com.nisovin.magicspells.castmodifiers.Condition; 6 | 7 | public abstract class OperatorCondition extends Condition { 8 | 9 | public boolean equals; 10 | public boolean moreThan; 11 | public boolean lessThan; 12 | 13 | @Override 14 | public boolean initialize(@NotNull String var) { 15 | switch (var.charAt(0)) { 16 | case '=', ':' -> equals = true; 17 | case '>' -> moreThan = true; 18 | case '<' -> lessThan = true; 19 | default -> { 20 | return false; 21 | } 22 | } 23 | return true; 24 | } 25 | 26 | protected boolean compare(double a, double b) { 27 | if (equals) return a == b; 28 | else if (moreThan) return a > b; 29 | else if (lessThan) return a < b; 30 | return false; 31 | } 32 | 33 | protected boolean compare(long a, long b) { 34 | if (equals) return a == b; 35 | else if (moreThan) return a > b; 36 | else if (lessThan) return a < b; 37 | return false; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/castmodifiers/customdata/CustomData.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.castmodifiers.customdata; 2 | 3 | public abstract class CustomData { 4 | 5 | public abstract boolean isValid(); 6 | 7 | public abstract String getInvalidText(); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/commands/HelpPermission.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.commands; 2 | 3 | import com.nisovin.magicspells.Perm; 4 | 5 | import java.lang.annotation.Target; 6 | import java.lang.annotation.Retention; 7 | import java.lang.annotation.ElementType; 8 | import java.lang.annotation.RetentionPolicy; 9 | 10 | @Retention(RetentionPolicy.RUNTIME) 11 | @Target(ElementType.METHOD) 12 | public @interface HelpPermission { 13 | 14 | Perm permission(); 15 | 16 | } 17 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/events/IMagicSpellsCompatEvent.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.events; 2 | 3 | public interface IMagicSpellsCompatEvent { 4 | //just here to group up all magicspells fired events 5 | } 6 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/events/MagicSpellsBlockBreakEvent.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.events; 2 | 3 | import org.bukkit.block.Block; 4 | import org.bukkit.entity.Player; 5 | import org.bukkit.event.block.BlockBreakEvent; 6 | 7 | public class MagicSpellsBlockBreakEvent extends BlockBreakEvent implements IMagicSpellsCompatEvent { 8 | 9 | public MagicSpellsBlockBreakEvent(Block theBlock, Player player) { 10 | super(theBlock, player); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/events/MagicSpellsBlockPlaceEvent.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.events; 2 | 3 | import org.bukkit.block.Block; 4 | import org.bukkit.entity.Player; 5 | import org.bukkit.block.BlockState; 6 | import org.bukkit.inventory.ItemStack; 7 | import org.bukkit.inventory.EquipmentSlot; 8 | import org.bukkit.event.block.BlockPlaceEvent; 9 | 10 | public class MagicSpellsBlockPlaceEvent extends BlockPlaceEvent implements IMagicSpellsCompatEvent { 11 | 12 | public MagicSpellsBlockPlaceEvent(Block placedBlock, BlockState replacedBlockState, Block placedAgainst, ItemStack itemInHand, Player thePlayer, boolean canBuild) { 13 | super(placedBlock, replacedBlockState, placedAgainst, itemInHand, thePlayer, canBuild, EquipmentSlot.HAND); 14 | } 15 | 16 | public MagicSpellsBlockPlaceEvent(Block placedBlock, BlockState replacedBlockState, Block placedAgainst, ItemStack itemInHand, Player thePlayer, boolean canBuild, EquipmentSlot equipmentSlot) { 17 | super(placedBlock, replacedBlockState, placedAgainst, itemInHand, thePlayer, canBuild, equipmentSlot); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/events/MagicSpellsEntityRegainHealthEvent.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.events; 2 | 3 | import org.bukkit.entity.Entity; 4 | import org.bukkit.event.entity.EntityRegainHealthEvent; 5 | 6 | public class MagicSpellsEntityRegainHealthEvent extends EntityRegainHealthEvent implements IMagicSpellsCompatEvent { 7 | 8 | public MagicSpellsEntityRegainHealthEvent(Entity entity, double amount, RegainReason regainReason) { 9 | super(entity, amount, regainReason); 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/events/MagicSpellsGenericPlayerEvent.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.events; 2 | 3 | import org.bukkit.event.Event; 4 | import org.bukkit.entity.Player; 5 | import org.bukkit.event.Cancellable; 6 | import org.bukkit.event.HandlerList; 7 | 8 | import org.jetbrains.annotations.NotNull; 9 | 10 | public class MagicSpellsGenericPlayerEvent extends Event implements Cancellable { 11 | 12 | private static final HandlerList handlers = new HandlerList(); 13 | 14 | private boolean cancelled = false; 15 | 16 | private final Player player; 17 | 18 | public MagicSpellsGenericPlayerEvent(Player player) { 19 | this.player = player; 20 | } 21 | 22 | public Player getPlayer() { 23 | return player; 24 | } 25 | 26 | @Override 27 | public boolean isCancelled() { 28 | return cancelled; 29 | } 30 | 31 | @Override 32 | public void setCancelled(boolean cancelled) { 33 | this.cancelled = cancelled; 34 | } 35 | 36 | @NotNull 37 | @Override 38 | public HandlerList getHandlers() { 39 | return handlers; 40 | } 41 | 42 | public static HandlerList getHandlerList() { 43 | return handlers; 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/events/MagicSpellsLoadedEvent.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.events; 2 | 3 | import org.bukkit.event.Event; 4 | import org.bukkit.event.HandlerList; 5 | 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | import com.nisovin.magicspells.MagicSpells; 9 | 10 | /** 11 | * This event is fired whenever MagicSpells finishes loading, either after the server first starts, 12 | * after a server reload (/reload), or after an internal reload (/ms reload). 13 | */ 14 | public class MagicSpellsLoadedEvent extends Event { 15 | 16 | private static final HandlerList handlers = new HandlerList(); 17 | 18 | private final MagicSpells plugin; 19 | 20 | public MagicSpellsLoadedEvent(MagicSpells plugin) { 21 | this.plugin = plugin; 22 | } 23 | 24 | /** 25 | * Gets the instance of the MagicSpells plugin 26 | * @return plugin instance 27 | */ 28 | public MagicSpells getPlugin() { 29 | return plugin; 30 | } 31 | 32 | @NotNull 33 | @Override 34 | public HandlerList getHandlers() { 35 | return handlers; 36 | } 37 | 38 | public static HandlerList getHandlerList() { 39 | return handlers; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/events/MagicSpellsLoadingEvent.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.events; 2 | 3 | import org.bukkit.event.Event; 4 | import org.bukkit.event.HandlerList; 5 | 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | import com.nisovin.magicspells.MagicSpells; 9 | 10 | /** 11 | * This event is fired whenever MagicSpells begins loading, either after the server first starts, 12 | * after a server reload (/reload), or after an internal reload (/ms reload). 13 | * 14 | */ 15 | public class MagicSpellsLoadingEvent extends Event { 16 | 17 | private static final HandlerList handlers = new HandlerList(); 18 | 19 | private final MagicSpells plugin; 20 | 21 | public MagicSpellsLoadingEvent(MagicSpells plugin) { 22 | this.plugin = plugin; 23 | } 24 | 25 | /** 26 | * Gets the instance of the MagicSpells plugin 27 | * @return plugin instance 28 | */ 29 | public MagicSpells getPlugin() { 30 | return plugin; 31 | } 32 | 33 | @NotNull 34 | @Override 35 | public HandlerList getHandlers() { 36 | return handlers; 37 | } 38 | 39 | public static HandlerList getHandlerList() { 40 | return handlers; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/events/MagicSpellsPlayerInteractEvent.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.events; 2 | 3 | import org.bukkit.block.Block; 4 | import org.bukkit.entity.Player; 5 | import org.bukkit.block.BlockFace; 6 | import org.bukkit.event.block.Action; 7 | import org.bukkit.inventory.ItemStack; 8 | import org.bukkit.event.player.PlayerInteractEvent; 9 | 10 | public class MagicSpellsPlayerInteractEvent extends PlayerInteractEvent implements IMagicSpellsCompatEvent { 11 | 12 | public MagicSpellsPlayerInteractEvent(Player who, Action action, ItemStack item, Block clickedBlock, BlockFace clickedFace) { 13 | super(who, action, item, clickedBlock, clickedFace); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/events/PortalEnterEvent.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.events; 2 | 3 | import org.bukkit.Location; 4 | import org.bukkit.entity.LivingEntity; 5 | 6 | import com.nisovin.magicspells.spells.instant.PortalSpell; 7 | 8 | /** 9 | * This event is fired whenever an entity enters a portal from {@link PortalSpell}. 10 | */ 11 | public class PortalEnterEvent extends PortalEvent { 12 | 13 | public PortalEnterEvent(LivingEntity entity, Location destination, PortalSpell portalSpell) { 14 | super(entity, destination, portalSpell); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/events/PortalLeaveEvent.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.events; 2 | 3 | import org.bukkit.Location; 4 | import org.bukkit.entity.LivingEntity; 5 | 6 | import com.nisovin.magicspells.spells.instant.PortalSpell; 7 | 8 | /** 9 | * This event is fired whenever an entity leaves a portal from {@link PortalSpell}. 10 | */ 11 | public class PortalLeaveEvent extends PortalEvent { 12 | 13 | public PortalLeaveEvent(LivingEntity entity, Location destination, PortalSpell portalSpell) { 14 | super(entity, destination, portalSpell); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/events/SpellSelectionChangeEvent.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.events; 2 | 3 | import org.bukkit.entity.Player; 4 | import org.bukkit.event.Cancellable; 5 | 6 | import com.nisovin.magicspells.Spell; 7 | import com.nisovin.magicspells.Spellbook; 8 | import com.nisovin.magicspells.util.CastItem; 9 | 10 | public class SpellSelectionChangeEvent extends SpellEvent implements Cancellable { 11 | 12 | private CastItem castItem; 13 | private Spellbook spellbook; 14 | 15 | private boolean cancelled = false; 16 | 17 | public SpellSelectionChangeEvent(Spell spell, Player caster, CastItem castItem, Spellbook spellbook) { 18 | super(spell, caster); 19 | this.castItem = castItem; 20 | this.spellbook = spellbook; 21 | } 22 | 23 | public CastItem getCastItem() { 24 | return castItem; 25 | } 26 | 27 | public Spellbook getSpellbook() { 28 | return spellbook; 29 | } 30 | 31 | @Override 32 | public boolean isCancelled() { 33 | return cancelled; 34 | } 35 | 36 | @Override 37 | public void setCancelled(boolean cancelled) { 38 | this.cancelled = cancelled; 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/events/SpellSelectionChangedEvent.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.events; 2 | 3 | import org.bukkit.entity.Player; 4 | 5 | import com.nisovin.magicspells.Spell; 6 | import com.nisovin.magicspells.Spellbook; 7 | import com.nisovin.magicspells.util.CastItem; 8 | 9 | public class SpellSelectionChangedEvent extends SpellEvent { 10 | 11 | private CastItem castItem; 12 | private Spellbook spellbook; 13 | 14 | public SpellSelectionChangedEvent(Spell spell, Player caster, CastItem castItem, Spellbook spellbook) { 15 | super(spell, caster); 16 | this.castItem = castItem; 17 | this.spellbook = spellbook; 18 | } 19 | 20 | public CastItem getCastItem() { 21 | return castItem; 22 | } 23 | 24 | public Spellbook getSpellbook() { 25 | return spellbook; 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/events/SpellbookReloadEvent.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.events; 2 | 3 | import org.bukkit.event.Event; 4 | import org.bukkit.entity.Player; 5 | import org.bukkit.event.HandlerList; 6 | 7 | import com.nisovin.magicspells.Spellbook; 8 | 9 | import org.jetbrains.annotations.NotNull; 10 | 11 | public class SpellbookReloadEvent extends Event { 12 | 13 | private static final HandlerList handlers = new HandlerList(); 14 | 15 | private Player player; 16 | 17 | private Spellbook spellBook; 18 | 19 | public SpellbookReloadEvent(Player player, Spellbook spellbook) { 20 | this.player = player; 21 | this.spellBook = spellbook; 22 | } 23 | 24 | public Player getPlayer() { 25 | return player; 26 | } 27 | 28 | public Spellbook getSpellBook() { 29 | return spellBook; 30 | } 31 | 32 | @NotNull 33 | @Override 34 | public HandlerList getHandlers() { 35 | return handlers; 36 | } 37 | 38 | public static HandlerList getHandlerList() { 39 | return handlers; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/events/TrackerMoveEvent.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.events; 2 | 3 | import org.bukkit.Location; 4 | import org.bukkit.event.Event; 5 | import org.bukkit.event.HandlerList; 6 | 7 | import org.jetbrains.annotations.NotNull; 8 | 9 | import com.nisovin.magicspells.util.trackers.Tracker; 10 | 11 | public class TrackerMoveEvent extends Event { 12 | 13 | private static final HandlerList handlers = new HandlerList(); 14 | 15 | private final Tracker tracker; 16 | 17 | private final Location from; 18 | private final Location to; 19 | 20 | public TrackerMoveEvent(Tracker tracker, Location from, Location to) { 21 | this.tracker = tracker; 22 | this.from = from; 23 | this.to = to; 24 | } 25 | 26 | public Tracker getTracker() { 27 | return tracker; 28 | } 29 | 30 | public Location getFrom() { 31 | return from; 32 | } 33 | 34 | public Location getTo() { 35 | return to; 36 | } 37 | 38 | @NotNull 39 | @Override 40 | public HandlerList getHandlers() { 41 | return handlers; 42 | } 43 | 44 | public static HandlerList getHandlerList() { 45 | return handlers; 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/exception/MagicException.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.exception; 2 | 3 | public class MagicException extends Exception { 4 | 5 | public MagicException(String message) { 6 | super(message); 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/handlers/EnchantmentHandler.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.handlers; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | 5 | import org.bukkit.NamespacedKey; 6 | import org.bukkit.enchantments.Enchantment; 7 | 8 | import io.papermc.paper.registry.RegistryKey; 9 | import io.papermc.paper.registry.RegistryAccess; 10 | 11 | public class EnchantmentHandler { 12 | 13 | public static Enchantment getEnchantment(@NotNull String name) { 14 | NamespacedKey key = NamespacedKey.fromString(name.toLowerCase()); 15 | return key == null ? null : RegistryAccess.registryAccess().getRegistry(RegistryKey.ENCHANTMENT).get(key); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/handlers/PotionEffectHandler.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.handlers; 2 | 3 | import java.util.Map; 4 | import java.util.HashMap; 5 | 6 | import org.bukkit.Registry; 7 | import org.bukkit.potion.PotionEffectType; 8 | 9 | public class PotionEffectHandler { 10 | 11 | private static final Map potionEffects = new HashMap<>(); 12 | 13 | static { 14 | // Add bukkit and minecraft potion effect names 15 | for (PotionEffectType potionEffect : Registry.EFFECT) { 16 | //noinspection deprecation 17 | potionEffects.put(potionEffect.getName().toLowerCase(), potionEffect); 18 | potionEffects.put(potionEffect.key().value(), potionEffect); 19 | } 20 | } 21 | 22 | public static PotionEffectType getPotionEffectType(String identification) { 23 | return potionEffects.get(identification.trim().toLowerCase()); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/mana/ManaChangeReason.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.mana; 2 | 3 | public enum ManaChangeReason { 4 | 5 | REGEN, 6 | SPELL_COST, 7 | POTION, 8 | OTHER 9 | 10 | } 11 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/spelleffects/effecttypes/DragonDeathEffect.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.spelleffects.effecttypes; 2 | 3 | import org.bukkit.Location; 4 | import org.bukkit.configuration.ConfigurationSection; 5 | 6 | import com.nisovin.magicspells.util.Name; 7 | import com.nisovin.magicspells.MagicSpells; 8 | import com.nisovin.magicspells.util.SpellData; 9 | import com.nisovin.magicspells.spelleffects.SpellEffect; 10 | 11 | @Name("dragondeath") 12 | public class DragonDeathEffect extends SpellEffect { 13 | 14 | @Override 15 | protected void loadFromConfig(ConfigurationSection config) { 16 | 17 | } 18 | 19 | @Override 20 | public Runnable playEffectLocation(Location location, SpellData data) { 21 | MagicSpells.getVolatileCodeHandler().playDragonDeathEffect(location); 22 | return null; 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/spelleffects/effecttypes/EffectLibEntityEffect.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.spelleffects.effecttypes; 2 | 3 | import org.bukkit.entity.Entity; 4 | 5 | import com.nisovin.magicspells.util.Name; 6 | import com.nisovin.magicspells.util.SpellData; 7 | 8 | @Name("effectlibentity") 9 | public class EffectLibEntityEffect extends EffectLibEffect { 10 | 11 | @Override 12 | protected Runnable playEffectEntity(final Entity e, final SpellData data) { 13 | if (!initialize()) return null; 14 | return manager.start(className, getParameters(data), e); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/spelleffects/effecttypes/EnderSignalEffect.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.spelleffects.effecttypes; 2 | 3 | import org.bukkit.Effect; 4 | import org.bukkit.Location; 5 | import org.bukkit.configuration.ConfigurationSection; 6 | 7 | import com.nisovin.magicspells.util.Name; 8 | import com.nisovin.magicspells.util.SpellData; 9 | import com.nisovin.magicspells.spelleffects.SpellEffect; 10 | 11 | @Name("ender") 12 | public class EnderSignalEffect extends SpellEffect { 13 | 14 | @Override 15 | public void loadFromConfig(ConfigurationSection config) { 16 | // TODO make a config loading schema 17 | } 18 | 19 | @Override 20 | public Runnable playEffectLocation(Location location, SpellData data) { 21 | location.getWorld().playEffect(location, Effect.ENDER_SIGNAL, 0); 22 | return null; 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/spelleffects/effecttypes/ExplosionEffect.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.spelleffects.effecttypes; 2 | 3 | import org.bukkit.Location; 4 | import org.bukkit.configuration.ConfigurationSection; 5 | 6 | import com.nisovin.magicspells.util.Name; 7 | import com.nisovin.magicspells.util.SpellData; 8 | import com.nisovin.magicspells.spelleffects.SpellEffect; 9 | 10 | @Name("explosion") 11 | public class ExplosionEffect extends SpellEffect { 12 | 13 | @Override 14 | public void loadFromConfig(ConfigurationSection config) { 15 | // TODO make a config loading schema 16 | } 17 | 18 | @Override 19 | public Runnable playEffectLocation(Location location, SpellData data) { 20 | location.getWorld().createExplosion(location, 0F); 21 | return null; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/spelleffects/effecttypes/LightningEffect.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.spelleffects.effecttypes; 2 | 3 | import org.bukkit.Location; 4 | import org.bukkit.configuration.ConfigurationSection; 5 | 6 | import com.nisovin.magicspells.util.Name; 7 | import com.nisovin.magicspells.util.SpellData; 8 | import com.nisovin.magicspells.spelleffects.SpellEffect; 9 | 10 | @Name("lightning") 11 | public class LightningEffect extends SpellEffect { 12 | 13 | @Override 14 | public void loadFromConfig(ConfigurationSection config) { 15 | // TODO make a config loading schema 16 | } 17 | 18 | @Override 19 | public Runnable playEffectLocation(Location location, SpellData data) { 20 | location.getWorld().strikeLightningEffect(location); 21 | return null; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/spelleffects/effecttypes/MobSpawnerEffect.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.spelleffects.effecttypes; 2 | 3 | import org.bukkit.Effect; 4 | import org.bukkit.Location; 5 | import org.bukkit.configuration.ConfigurationSection; 6 | 7 | import com.nisovin.magicspells.util.Name; 8 | import com.nisovin.magicspells.util.SpellData; 9 | import com.nisovin.magicspells.spelleffects.SpellEffect; 10 | 11 | @Name("spawn") 12 | public class MobSpawnerEffect extends SpellEffect { 13 | 14 | @Override 15 | public void loadFromConfig(ConfigurationSection config) { 16 | //TODO make a config schema for this effect 17 | } 18 | 19 | @Override 20 | public Runnable playEffectLocation(Location location, SpellData data) { 21 | location.getWorld().playEffect(location, Effect.MOBSPAWNER_FLAMES, 0); 22 | return null; 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/spelleffects/effecttypes/SplashPotionEffect.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.spelleffects.effecttypes; 2 | 3 | import org.bukkit.Effect; 4 | import org.bukkit.Location; 5 | import org.bukkit.configuration.ConfigurationSection; 6 | 7 | import com.nisovin.magicspells.util.Name; 8 | import com.nisovin.magicspells.util.SpellData; 9 | import com.nisovin.magicspells.util.config.ConfigData; 10 | import com.nisovin.magicspells.spelleffects.SpellEffect; 11 | import com.nisovin.magicspells.util.config.ConfigDataUtil; 12 | 13 | @Name("splash") 14 | public class SplashPotionEffect extends SpellEffect { 15 | 16 | private ConfigData pot; 17 | 18 | @Override 19 | public void loadFromConfig(ConfigurationSection config) { 20 | pot = ConfigDataUtil.getInteger(config, "potion", 0); 21 | } 22 | 23 | @Override 24 | public Runnable playEffectLocation(Location location, SpellData data) { 25 | location.getWorld().playEffect(location, Effect.POTION_BREAK, (int) pot.get(data)); 26 | return null; 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/spelleffects/util/EffectlibSpellEffect.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.spelleffects.util; 2 | 3 | import de.slikey.effectlib.Effect; 4 | 5 | import org.jetbrains.annotations.NotNull; 6 | 7 | import com.nisovin.magicspells.spelleffects.effecttypes.EffectLibEffect; 8 | 9 | public class EffectlibSpellEffect { 10 | 11 | @NotNull 12 | private Effect effect; 13 | 14 | @NotNull 15 | private EffectLibEffect spellEffect; 16 | 17 | public EffectlibSpellEffect(@NotNull Effect effect, @NotNull EffectLibEffect spellEffect) { 18 | this.effect = effect; 19 | this.spellEffect = spellEffect; 20 | } 21 | 22 | @NotNull 23 | public Effect getEffect() { 24 | return effect; 25 | } 26 | 27 | public void setEffect(@NotNull Effect effect) { 28 | this.effect = effect; 29 | } 30 | 31 | @NotNull 32 | public EffectLibEffect getSpellEffect() { 33 | return spellEffect; 34 | } 35 | 36 | public void setSpellEffect(@NotNull EffectLibEffect spellEffect) { 37 | this.spellEffect = spellEffect; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/spells/CommandSpell.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.spells; 2 | 3 | import java.util.List; 4 | 5 | import org.bukkit.command.CommandSender; 6 | 7 | import com.nisovin.magicspells.Spell; 8 | import com.nisovin.magicspells.util.MagicConfig; 9 | 10 | public abstract class CommandSpell extends Spell { 11 | 12 | public CommandSpell(MagicConfig config, String spellName) { 13 | super(config, spellName); 14 | } 15 | 16 | @Override 17 | public boolean canCastWithItem() { 18 | return false; 19 | } 20 | 21 | @Override 22 | public boolean canCastByCommand() { 23 | return true; 24 | } 25 | 26 | @Override 27 | public abstract boolean castFromConsole(CommandSender sender, String[] args); 28 | 29 | @Override 30 | public abstract List tabComplete(CommandSender sender, String[] args); 31 | 32 | } 33 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/spells/DamageSpell.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.spells; 2 | 3 | import com.nisovin.magicspells.events.SpellApplyDamageEvent; 4 | 5 | /** 6 | * @deprecated "Spell damage type" string is now on {@link SpellApplyDamageEvent}. 7 | */ 8 | @Deprecated(forRemoval = true) 9 | public interface DamageSpell { 10 | 11 | @Deprecated(forRemoval = true) 12 | String getSpellDamageType(); 13 | 14 | } 15 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/spells/InstantSpell.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.spells; 2 | 3 | import com.nisovin.magicspells.Spell; 4 | import com.nisovin.magicspells.util.MagicConfig; 5 | 6 | public abstract class InstantSpell extends Spell { 7 | 8 | private boolean castWithItem; 9 | private boolean castByCommand; 10 | 11 | public InstantSpell(MagicConfig config, String spellName) { 12 | super(config, spellName); 13 | 14 | castWithItem = getConfigBoolean("can-cast-with-item", true); 15 | castByCommand = getConfigBoolean("can-cast-by-command", true); 16 | } 17 | 18 | @Override 19 | public boolean canCastWithItem() { 20 | return castWithItem; 21 | } 22 | 23 | @Override 24 | public boolean canCastByCommand() { 25 | return castByCommand; 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/spells/TargetedEntitySpell.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.spells; 2 | 3 | import org.bukkit.entity.LivingEntity; 4 | 5 | import com.nisovin.magicspells.util.SpellData; 6 | import com.nisovin.magicspells.util.CastResult; 7 | import com.nisovin.magicspells.Spell.PostCastAction; 8 | 9 | public interface TargetedEntitySpell { 10 | 11 | default CastResult castAtEntity(SpellData data) { 12 | boolean success = data.hasCaster() ? 13 | castAtEntity(data.caster(), data.target(), data.power()) : 14 | castAtEntity(data.target(), data.power()); 15 | 16 | return new CastResult(success ? PostCastAction.HANDLE_NORMALLY : PostCastAction.ALREADY_HANDLED, data); 17 | } 18 | 19 | @Deprecated 20 | default boolean castAtEntity(LivingEntity caster, LivingEntity target, float power) { 21 | return castAtEntity(new SpellData(caster, target, power, null)).action() != PostCastAction.ALREADY_HANDLED; 22 | } 23 | 24 | @Deprecated 25 | default boolean castAtEntity(LivingEntity target, float power) { 26 | return castAtEntity(new SpellData(null, target, power, null)).action() != PostCastAction.ALREADY_HANDLED; 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/spells/instant/CraftSpell.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.spells.instant; 2 | 3 | import org.bukkit.entity.Player; 4 | 5 | import com.nisovin.magicspells.util.SpellData; 6 | import com.nisovin.magicspells.util.CastResult; 7 | import com.nisovin.magicspells.util.MagicConfig; 8 | import com.nisovin.magicspells.spells.InstantSpell; 9 | 10 | public class CraftSpell extends InstantSpell { 11 | 12 | public CraftSpell(MagicConfig config, String spellName) { 13 | super(config, spellName); 14 | } 15 | 16 | @Override 17 | public CastResult cast(SpellData data) { 18 | if (!(data.caster() instanceof Player caster)) return new CastResult(PostCastAction.ALREADY_HANDLED, data); 19 | 20 | caster.openWorkbench(null, true); 21 | playSpellEffects(data); 22 | 23 | return new CastResult(PostCastAction.HANDLE_NORMALLY, data); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/spells/instant/DummySpell.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.spells.instant; 2 | 3 | import org.bukkit.command.CommandSender; 4 | 5 | import com.nisovin.magicspells.util.SpellData; 6 | import com.nisovin.magicspells.util.CastResult; 7 | import com.nisovin.magicspells.util.MagicConfig; 8 | import com.nisovin.magicspells.spells.InstantSpell; 9 | 10 | public class DummySpell extends InstantSpell { 11 | 12 | public DummySpell(MagicConfig config, String spellName) { 13 | super(config, spellName); 14 | } 15 | 16 | @Override 17 | public CastResult cast(SpellData data) { 18 | playSpellEffects(data); 19 | return new CastResult(PostCastAction.HANDLE_NORMALLY, data); 20 | } 21 | 22 | @Override 23 | public boolean castFromConsole(CommandSender sender, String[] args) { 24 | return true; 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/spells/passive/DeathListener.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.spells.passive; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | 5 | import org.bukkit.event.EventHandler; 6 | import org.bukkit.entity.LivingEntity; 7 | import org.bukkit.event.entity.EntityDeathEvent; 8 | 9 | import com.nisovin.magicspells.util.Name; 10 | import com.nisovin.magicspells.util.OverridePriority; 11 | import com.nisovin.magicspells.spells.passive.util.PassiveListener; 12 | 13 | @Name("death") 14 | public class DeathListener extends PassiveListener { 15 | 16 | @Override 17 | public void initialize(@NotNull String var) { 18 | } 19 | 20 | @OverridePriority 21 | @EventHandler 22 | public void onDeath(EntityDeathEvent event) { 23 | LivingEntity entity = event.getEntity(); 24 | if (!canTrigger(entity)) return; 25 | 26 | boolean casted = passiveSpell.activate(entity); 27 | if (cancelDefaultAction(casted)) event.setCancelled(true); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/spells/passive/EnterBedListener.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.spells.passive; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | 5 | import org.bukkit.entity.Player; 6 | import org.bukkit.event.EventHandler; 7 | import org.bukkit.event.player.PlayerBedEnterEvent; 8 | 9 | import com.nisovin.magicspells.util.Name; 10 | import com.nisovin.magicspells.util.OverridePriority; 11 | import com.nisovin.magicspells.spells.passive.util.PassiveListener; 12 | 13 | @Name("enterbed") 14 | public class EnterBedListener extends PassiveListener { 15 | 16 | @Override 17 | public void initialize(@NotNull String var) { 18 | } 19 | 20 | @OverridePriority 21 | @EventHandler 22 | public void onDeath(PlayerBedEnterEvent event) { 23 | if (!isCancelStateOk(event.isCancelled())) return; 24 | 25 | Player player = event.getPlayer(); 26 | if (!canTrigger(player)) return; 27 | 28 | boolean casted = passiveSpell.activate(player); 29 | if (cancelDefaultAction(casted)) event.setCancelled(true); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/spells/passive/JoinListener.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.spells.passive; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | 5 | import org.bukkit.entity.Player; 6 | import org.bukkit.event.EventHandler; 7 | import org.bukkit.event.player.PlayerJoinEvent; 8 | 9 | import com.nisovin.magicspells.util.Name; 10 | import com.nisovin.magicspells.util.OverridePriority; 11 | import com.nisovin.magicspells.spells.passive.util.PassiveListener; 12 | 13 | @Name("join") 14 | public class JoinListener extends PassiveListener { 15 | 16 | @Override 17 | public void initialize(@NotNull String var) { 18 | } 19 | 20 | @OverridePriority 21 | @EventHandler 22 | public void onJoin(PlayerJoinEvent event) { 23 | Player caster = event.getPlayer(); 24 | if (!canTrigger(caster)) return; 25 | 26 | passiveSpell.activate(caster); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/spells/passive/LeaveBedListener.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.spells.passive; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | 5 | import org.bukkit.entity.Player; 6 | import org.bukkit.event.EventHandler; 7 | import org.bukkit.event.player.PlayerBedLeaveEvent; 8 | 9 | import com.nisovin.magicspells.util.Name; 10 | import com.nisovin.magicspells.util.OverridePriority; 11 | import com.nisovin.magicspells.spells.passive.util.PassiveListener; 12 | 13 | @Name("leavebed") 14 | public class LeaveBedListener extends PassiveListener { 15 | 16 | @Override 17 | public void initialize(@NotNull String var) { 18 | } 19 | 20 | @OverridePriority 21 | @EventHandler 22 | public void onDeath(PlayerBedLeaveEvent event) { 23 | if (!isCancelStateOk(event.isCancelled())) return; 24 | 25 | Player caster = event.getPlayer(); 26 | if (!canTrigger(caster)) return; 27 | 28 | boolean casted = passiveSpell.activate(event.getPlayer()); 29 | if (cancelDefaultAction(casted)) event.setCancelled(true); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/spells/passive/MagicSpellsLoadedListener.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.spells.passive; 2 | 3 | import org.bukkit.World; 4 | import org.bukkit.Bukkit; 5 | import org.bukkit.event.EventHandler; 6 | import org.bukkit.entity.LivingEntity; 7 | 8 | import org.jetbrains.annotations.NotNull; 9 | 10 | import com.nisovin.magicspells.util.Name; 11 | import com.nisovin.magicspells.util.OverridePriority; 12 | import com.nisovin.magicspells.events.MagicSpellsLoadedEvent; 13 | import com.nisovin.magicspells.spells.passive.util.PassiveListener; 14 | 15 | @Name("magicspellsloaded") 16 | public class MagicSpellsLoadedListener extends PassiveListener { 17 | 18 | @Override 19 | public void initialize(@NotNull String var) { 20 | } 21 | 22 | @OverridePriority 23 | @EventHandler 24 | public void onLoaded(MagicSpellsLoadedEvent e) { 25 | for (World world : Bukkit.getWorlds()) 26 | for (LivingEntity livingEntity : world.getLivingEntities()) 27 | if (canTrigger(livingEntity)) passiveSpell.activate(livingEntity); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/spells/passive/OffhandSwapListener.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.spells.passive; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | 5 | import org.bukkit.entity.Player; 6 | import org.bukkit.event.EventHandler; 7 | import org.bukkit.event.player.PlayerSwapHandItemsEvent; 8 | 9 | import com.nisovin.magicspells.util.Name; 10 | import com.nisovin.magicspells.util.OverridePriority; 11 | import com.nisovin.magicspells.spells.passive.util.PassiveListener; 12 | 13 | @Name("offhandswap") 14 | public class OffhandSwapListener extends PassiveListener { 15 | 16 | @Override 17 | public void initialize(@NotNull String var) { 18 | } 19 | 20 | @OverridePriority 21 | @EventHandler 22 | public void onSwap(PlayerSwapHandItemsEvent event) { 23 | if (!isCancelStateOk(event.isCancelled())) return; 24 | 25 | Player caster = event.getPlayer(); 26 | if (!canTrigger(caster)) return; 27 | 28 | boolean casted = passiveSpell.activate(caster); 29 | if (cancelDefaultAction(casted)) event.setCancelled(true); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/spells/passive/PlayerMoveToBlockListener.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.spells.passive; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | 5 | import org.bukkit.entity.Player; 6 | import org.bukkit.event.EventHandler; 7 | import org.bukkit.event.player.PlayerMoveEvent; 8 | 9 | import com.nisovin.magicspells.util.Name; 10 | import com.nisovin.magicspells.util.OverridePriority; 11 | import com.nisovin.magicspells.spells.passive.util.PassiveListener; 12 | 13 | @Name("playermovetoblock") 14 | public class PlayerMoveToBlockListener extends PassiveListener { 15 | 16 | @Override 17 | public void initialize(@NotNull String var) { 18 | } 19 | 20 | @OverridePriority 21 | @EventHandler 22 | public void onMove(PlayerMoveEvent event) { 23 | if (!isCancelStateOk(event.isCancelled())) return; 24 | 25 | Player caster = event.getPlayer(); 26 | if (!canTrigger(caster) || !event.hasChangedBlock()) return; 27 | 28 | boolean casted = passiveSpell.activate(caster); 29 | if (cancelDefaultAction(casted)) event.setCancelled(true); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/spells/passive/QuitListener.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.spells.passive; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | 5 | import org.bukkit.entity.Player; 6 | import org.bukkit.event.EventHandler; 7 | import org.bukkit.event.player.PlayerQuitEvent; 8 | 9 | import com.nisovin.magicspells.util.Name; 10 | import com.nisovin.magicspells.util.OverridePriority; 11 | import com.nisovin.magicspells.spells.passive.util.PassiveListener; 12 | 13 | @Name("quit") 14 | public class QuitListener extends PassiveListener { 15 | 16 | @Override 17 | public void initialize(@NotNull String var) { 18 | } 19 | 20 | @OverridePriority 21 | @EventHandler 22 | public void onQuit(PlayerQuitEvent event) { 23 | Player caster = event.getPlayer(); 24 | if (!canTrigger(caster)) return; 25 | 26 | passiveSpell.activate(caster); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/spells/passive/RespawnListener.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.spells.passive; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | 5 | import org.bukkit.entity.Player; 6 | import org.bukkit.event.EventHandler; 7 | import org.bukkit.event.player.PlayerRespawnEvent; 8 | 9 | import com.nisovin.magicspells.util.Name; 10 | import com.nisovin.magicspells.util.OverridePriority; 11 | import com.nisovin.magicspells.spells.passive.util.PassiveListener; 12 | 13 | @Name("respawn") 14 | public class RespawnListener extends PassiveListener { 15 | 16 | @Override 17 | public void initialize(@NotNull String var) { 18 | } 19 | 20 | @OverridePriority 21 | @EventHandler 22 | public void onRespawn(PlayerRespawnEvent event) { 23 | Player caster = event.getPlayer(); 24 | if (!canTrigger(caster)) return; 25 | 26 | passiveSpell.activate(caster); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/spells/passive/ShootListener.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.spells.passive; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | 5 | import org.bukkit.event.EventHandler; 6 | import org.bukkit.entity.LivingEntity; 7 | import org.bukkit.event.entity.EntityShootBowEvent; 8 | 9 | import com.nisovin.magicspells.util.Name; 10 | import com.nisovin.magicspells.util.OverridePriority; 11 | import com.nisovin.magicspells.spells.passive.util.PassiveListener; 12 | 13 | @Name("shoot") 14 | public class ShootListener extends PassiveListener { 15 | 16 | @Override 17 | public void initialize(@NotNull String var) { 18 | } 19 | 20 | @OverridePriority 21 | @EventHandler 22 | public void onShoot(final EntityShootBowEvent event) { 23 | if (!isCancelStateOk(event.isCancelled())) return; 24 | 25 | LivingEntity caster = event.getEntity(); 26 | if (!canTrigger(caster)) return; 27 | 28 | boolean casted = passiveSpell.activate(caster, event.getForce()); 29 | if (cancelDefaultAction(casted)) { 30 | event.setCancelled(true); 31 | event.getProjectile().remove(); 32 | } 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/spells/passive/StartFlyListener.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.spells.passive; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | 5 | import org.bukkit.entity.Player; 6 | import org.bukkit.event.EventHandler; 7 | import org.bukkit.event.player.PlayerToggleFlightEvent; 8 | 9 | import com.nisovin.magicspells.util.Name; 10 | import com.nisovin.magicspells.util.OverridePriority; 11 | import com.nisovin.magicspells.spells.passive.util.PassiveListener; 12 | 13 | @Name("startfly") 14 | public class StartFlyListener extends PassiveListener { 15 | 16 | @Override 17 | public void initialize(@NotNull String var) { 18 | } 19 | 20 | @OverridePriority 21 | @EventHandler 22 | public void onFly(PlayerToggleFlightEvent event) { 23 | if (!isCancelStateOk(event.isCancelled())) return; 24 | if (!event.isFlying()) return; 25 | 26 | Player caster = event.getPlayer(); 27 | if (!canTrigger(caster)) return; 28 | 29 | boolean casted = passiveSpell.activate(caster); 30 | if (cancelDefaultAction(casted)) event.setCancelled(true); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/spells/passive/StartGlideListener.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.spells.passive; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | 5 | import org.bukkit.event.EventHandler; 6 | import org.bukkit.entity.LivingEntity; 7 | import org.bukkit.event.entity.EntityToggleGlideEvent; 8 | 9 | import com.nisovin.magicspells.util.Name; 10 | import com.nisovin.magicspells.util.OverridePriority; 11 | import com.nisovin.magicspells.spells.passive.util.PassiveListener; 12 | 13 | @Name("startglide") 14 | public class StartGlideListener extends PassiveListener { 15 | 16 | @Override 17 | public void initialize(@NotNull String var) { 18 | } 19 | 20 | @OverridePriority 21 | @EventHandler 22 | public void onGlide(EntityToggleGlideEvent event) { 23 | if (!(event.getEntity() instanceof LivingEntity caster)) return; 24 | if (!isCancelStateOk(event.isCancelled())) return; 25 | if (!event.isGliding()) return; 26 | if (!canTrigger(caster)) return; 27 | 28 | boolean casted = passiveSpell.activate(caster); 29 | if (cancelDefaultAction(casted)) event.setCancelled(true); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/spells/passive/StartSneakListener.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.spells.passive; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | 5 | import org.bukkit.entity.Player; 6 | import org.bukkit.event.EventHandler; 7 | import org.bukkit.event.player.PlayerToggleSneakEvent; 8 | 9 | import com.nisovin.magicspells.util.Name; 10 | import com.nisovin.magicspells.util.OverridePriority; 11 | import com.nisovin.magicspells.spells.passive.util.PassiveListener; 12 | 13 | @Name("startsneak") 14 | public class StartSneakListener extends PassiveListener { 15 | 16 | @Override 17 | public void initialize(@NotNull String var) { 18 | } 19 | 20 | @OverridePriority 21 | @EventHandler 22 | public void onSneak(PlayerToggleSneakEvent event) { 23 | if (!isCancelStateOk(event.isCancelled())) return; 24 | if (!event.isSneaking()) return; 25 | 26 | Player caster = event.getPlayer(); 27 | if (!canTrigger(caster)) return; 28 | 29 | boolean casted = passiveSpell.activate(event.getPlayer()); 30 | if (cancelDefaultAction(casted)) event.setCancelled(true); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/spells/passive/StartSprintListener.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.spells.passive; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | 5 | import org.bukkit.entity.Player; 6 | import org.bukkit.event.EventHandler; 7 | import org.bukkit.event.player.PlayerToggleSprintEvent; 8 | 9 | import com.nisovin.magicspells.util.Name; 10 | import com.nisovin.magicspells.util.OverridePriority; 11 | import com.nisovin.magicspells.spells.passive.util.PassiveListener; 12 | 13 | @Name("startsprint") 14 | public class StartSprintListener extends PassiveListener { 15 | 16 | @Override 17 | public void initialize(@NotNull String var) { 18 | } 19 | 20 | @OverridePriority 21 | @EventHandler 22 | public void onSprint(PlayerToggleSprintEvent event) { 23 | if (!isCancelStateOk(event.isCancelled())) return; 24 | 25 | Player caster = event.getPlayer(); 26 | if (!event.isSprinting() || !canTrigger(caster)) return; 27 | 28 | boolean casted = passiveSpell.activate(caster); 29 | if (cancelDefaultAction(casted)) event.setCancelled(true); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/spells/passive/StartSwimListener.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.spells.passive; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | 5 | import org.bukkit.event.EventHandler; 6 | import org.bukkit.entity.LivingEntity; 7 | import org.bukkit.event.entity.EntityToggleSwimEvent; 8 | 9 | import com.nisovin.magicspells.util.Name; 10 | import com.nisovin.magicspells.util.OverridePriority; 11 | import com.nisovin.magicspells.spells.passive.util.PassiveListener; 12 | 13 | @Name("startswim") 14 | public class StartSwimListener extends PassiveListener { 15 | 16 | @Override 17 | public void initialize(@NotNull String var) { 18 | } 19 | 20 | @OverridePriority 21 | @EventHandler 22 | public void onSwim(EntityToggleSwimEvent event) { 23 | if (!(event.getEntity() instanceof LivingEntity caster)) return; 24 | if (!event.isSwimming()) return; 25 | if (!canTrigger(caster)) return; 26 | passiveSpell.activate(caster); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/spells/passive/StopFlyListener.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.spells.passive; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | 5 | import org.bukkit.entity.Player; 6 | import org.bukkit.event.EventHandler; 7 | import org.bukkit.event.player.PlayerToggleFlightEvent; 8 | 9 | import com.nisovin.magicspells.util.Name; 10 | import com.nisovin.magicspells.util.OverridePriority; 11 | import com.nisovin.magicspells.spells.passive.util.PassiveListener; 12 | 13 | @Name("stopfly") 14 | public class StopFlyListener extends PassiveListener { 15 | 16 | @Override 17 | public void initialize(@NotNull String var) { 18 | } 19 | 20 | @OverridePriority 21 | @EventHandler 22 | public void onFly(PlayerToggleFlightEvent event) { 23 | if (!isCancelStateOk(event.isCancelled())) return; 24 | if (event.isFlying()) return; 25 | 26 | Player caster = event.getPlayer(); 27 | if (!canTrigger(caster)) return; 28 | 29 | boolean casted = passiveSpell.activate(caster); 30 | if (cancelDefaultAction(casted)) event.setCancelled(true); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/spells/passive/StopGlideListener.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.spells.passive; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | 5 | import org.bukkit.event.EventHandler; 6 | import org.bukkit.entity.LivingEntity; 7 | import org.bukkit.event.entity.EntityToggleGlideEvent; 8 | 9 | import com.nisovin.magicspells.util.Name; 10 | import com.nisovin.magicspells.util.OverridePriority; 11 | import com.nisovin.magicspells.spells.passive.util.PassiveListener; 12 | 13 | @Name("stopglide") 14 | public class StopGlideListener extends PassiveListener { 15 | 16 | @Override 17 | public void initialize(@NotNull String var) { 18 | } 19 | 20 | @OverridePriority 21 | @EventHandler 22 | public void onGlide(EntityToggleGlideEvent event) { 23 | if (!(event.getEntity() instanceof LivingEntity caster)) return; 24 | if (!isCancelStateOk(event.isCancelled())) return; 25 | if (event.isGliding()) return; 26 | if (!canTrigger(caster)) return; 27 | 28 | boolean casted = passiveSpell.activate(caster); 29 | if (cancelDefaultAction(casted)) event.setCancelled(true); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/spells/passive/StopSneakListener.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.spells.passive; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | 5 | import org.bukkit.entity.Player; 6 | import org.bukkit.event.EventHandler; 7 | import org.bukkit.event.player.PlayerToggleSneakEvent; 8 | 9 | import com.nisovin.magicspells.util.Name; 10 | import com.nisovin.magicspells.util.OverridePriority; 11 | import com.nisovin.magicspells.spells.passive.util.PassiveListener; 12 | 13 | @Name("stopsneak") 14 | public class StopSneakListener extends PassiveListener { 15 | 16 | @Override 17 | public void initialize(@NotNull String var) { 18 | } 19 | 20 | @OverridePriority 21 | @EventHandler 22 | public void onSneak(PlayerToggleSneakEvent event) { 23 | if (!isCancelStateOk(event.isCancelled())) return; 24 | if (event.isSneaking()) return; 25 | 26 | Player caster = event.getPlayer(); 27 | if (!canTrigger(caster)) return; 28 | 29 | boolean casted = passiveSpell.activate(caster); 30 | if (cancelDefaultAction(casted)) event.setCancelled(true); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/spells/passive/StopSprintListener.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.spells.passive; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | 5 | import org.bukkit.entity.Player; 6 | import org.bukkit.event.EventHandler; 7 | import org.bukkit.event.player.PlayerToggleSprintEvent; 8 | 9 | import com.nisovin.magicspells.util.Name; 10 | import com.nisovin.magicspells.util.OverridePriority; 11 | import com.nisovin.magicspells.spells.passive.util.PassiveListener; 12 | 13 | @Name("stopsprint") 14 | public class StopSprintListener extends PassiveListener { 15 | 16 | @Override 17 | public void initialize(@NotNull String var) { 18 | } 19 | 20 | @OverridePriority 21 | @EventHandler 22 | public void onSprint(PlayerToggleSprintEvent event) { 23 | if (!isCancelStateOk(event.isCancelled())) return; 24 | if (event.isSprinting()) return; 25 | 26 | Player caster = event.getPlayer(); 27 | if (!canTrigger(caster)) return; 28 | 29 | boolean casted = passiveSpell.activate(caster); 30 | if (cancelDefaultAction(casted)) event.setCancelled(true); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/spells/passive/StopSwimListener.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.spells.passive; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | 5 | import org.bukkit.event.EventHandler; 6 | import org.bukkit.entity.LivingEntity; 7 | import org.bukkit.event.entity.EntityToggleSwimEvent; 8 | 9 | import com.nisovin.magicspells.util.Name; 10 | import com.nisovin.magicspells.util.OverridePriority; 11 | import com.nisovin.magicspells.spells.passive.util.PassiveListener; 12 | 13 | @Name("stopswim") 14 | public class StopSwimListener extends PassiveListener { 15 | 16 | @Override 17 | public void initialize(@NotNull String var) { 18 | } 19 | 20 | @OverridePriority 21 | @EventHandler 22 | public void onSwim(EntityToggleSwimEvent event) { 23 | if (!(event.getEntity() instanceof LivingEntity caster)) return; 24 | if (event.isSwimming()) return; 25 | if (!canTrigger(caster)) return; 26 | passiveSpell.activate(caster); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/spells/targeted/cleanse/BuffSpellCleanser.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.spells.targeted.cleanse; 2 | 3 | import java.util.function.BiConsumer; 4 | import java.util.function.BiPredicate; 5 | 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | import org.bukkit.entity.LivingEntity; 9 | 10 | import com.nisovin.magicspells.spells.BuffSpell; 11 | import com.nisovin.magicspells.spells.targeted.cleanse.util.SpellCleanser; 12 | 13 | public class BuffSpellCleanser extends SpellCleanser { 14 | 15 | @Override 16 | protected @NotNull String getPrefix() { 17 | return "buff"; 18 | } 19 | 20 | @Override 21 | protected @NotNull Class getSpellClass() { 22 | return BuffSpell.class; 23 | } 24 | 25 | @Override 26 | protected @NotNull BiPredicate getIsActive() { 27 | return BuffSpell::isActive; 28 | } 29 | 30 | @Override 31 | protected @NotNull BiConsumer getCleanse() { 32 | return BuffSpell::turnOff; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/spells/targeted/cleanse/DotSpellCleanser.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.spells.targeted.cleanse; 2 | 3 | import java.util.function.BiConsumer; 4 | import java.util.function.BiPredicate; 5 | 6 | import org.bukkit.entity.LivingEntity; 7 | 8 | import org.jetbrains.annotations.NotNull; 9 | 10 | import com.nisovin.magicspells.spells.targeted.DotSpell; 11 | import com.nisovin.magicspells.spells.targeted.cleanse.util.SpellCleanser; 12 | 13 | public class DotSpellCleanser extends SpellCleanser { 14 | 15 | @Override 16 | protected @NotNull String getPrefix() { 17 | return "dot"; 18 | } 19 | 20 | @Override 21 | protected @NotNull Class getSpellClass() { 22 | return DotSpell.class; 23 | } 24 | 25 | @Override 26 | protected @NotNull BiPredicate getIsActive() { 27 | return DotSpell::isActive; 28 | } 29 | 30 | @Override 31 | protected @NotNull BiConsumer getCleanse() { 32 | return DotSpell::cancelDot; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/spells/targeted/cleanse/FireCleanser.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.spells.targeted.cleanse; 2 | 3 | import org.bukkit.entity.LivingEntity; 4 | 5 | import org.jetbrains.annotations.NotNull; 6 | 7 | import com.nisovin.magicspells.spells.targeted.cleanse.util.Cleanser; 8 | 9 | public class FireCleanser implements Cleanser { 10 | 11 | private static final String NAME = "fire"; 12 | 13 | @Override 14 | public boolean add(@NotNull String string) { 15 | return string.equalsIgnoreCase(NAME); 16 | } 17 | 18 | @Override 19 | public boolean isAnyActive(@NotNull LivingEntity entity) { 20 | return entity.getFireTicks() > 0; 21 | } 22 | 23 | @Override 24 | public void cleanse(@NotNull LivingEntity entity) { 25 | entity.setFireTicks(0); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/spells/targeted/cleanse/FreezeCleanser.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.spells.targeted.cleanse; 2 | 3 | import org.bukkit.entity.LivingEntity; 4 | 5 | import org.jetbrains.annotations.NotNull; 6 | 7 | import com.nisovin.magicspells.spells.targeted.cleanse.util.Cleanser; 8 | 9 | public class FreezeCleanser implements Cleanser { 10 | 11 | private static final String NAME = "freeze"; 12 | 13 | @Override 14 | public boolean add(@NotNull String string) { 15 | return string.equalsIgnoreCase(NAME); 16 | } 17 | 18 | @Override 19 | public boolean isAnyActive(@NotNull LivingEntity entity) { 20 | return entity.getFreezeTicks() > 0; 21 | } 22 | 23 | @Override 24 | public void cleanse(@NotNull LivingEntity entity) { 25 | entity.setFreezeTicks(0); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/spells/targeted/cleanse/LevitateSpellCleanser.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.spells.targeted.cleanse; 2 | 3 | import java.util.function.BiConsumer; 4 | import java.util.function.BiPredicate; 5 | 6 | import org.bukkit.entity.LivingEntity; 7 | 8 | import org.jetbrains.annotations.NotNull; 9 | 10 | import com.nisovin.magicspells.spells.targeted.LevitateSpell; 11 | import com.nisovin.magicspells.spells.targeted.cleanse.util.SpellCleanser; 12 | 13 | public class LevitateSpellCleanser extends SpellCleanser { 14 | 15 | @Override 16 | protected @NotNull String getPrefix() { 17 | return "levitate"; 18 | } 19 | 20 | @Override 21 | protected @NotNull Class getSpellClass() { 22 | return LevitateSpell.class; 23 | } 24 | 25 | @Override 26 | protected @NotNull BiPredicate getIsActive() { 27 | return LevitateSpell::isBeingLevitated; 28 | } 29 | 30 | @Override 31 | protected @NotNull BiConsumer getCleanse() { 32 | return LevitateSpell::removeLevitate; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/spells/targeted/cleanse/LoopSpellCleanser.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.spells.targeted.cleanse; 2 | 3 | import java.util.function.BiConsumer; 4 | import java.util.function.BiPredicate; 5 | 6 | import org.bukkit.entity.LivingEntity; 7 | 8 | import org.jetbrains.annotations.NotNull; 9 | 10 | import com.nisovin.magicspells.spells.targeted.LoopSpell; 11 | import com.nisovin.magicspells.spells.targeted.cleanse.util.SpellCleanser; 12 | 13 | public class LoopSpellCleanser extends SpellCleanser { 14 | 15 | @Override 16 | protected @NotNull String getPrefix() { 17 | return "loop"; 18 | } 19 | 20 | @Override 21 | protected @NotNull Class getSpellClass() { 22 | return LoopSpell.class; 23 | } 24 | 25 | @Override 26 | protected @NotNull BiPredicate getIsActive() { 27 | return LoopSpell::isActive; 28 | } 29 | 30 | @Override 31 | protected @NotNull BiConsumer getCleanse() { 32 | return LoopSpell::cancelLoops; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/spells/targeted/cleanse/OrbitSpellCleanser.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.spells.targeted.cleanse; 2 | 3 | import java.util.function.BiConsumer; 4 | import java.util.function.BiPredicate; 5 | 6 | import org.bukkit.entity.LivingEntity; 7 | 8 | import org.jetbrains.annotations.NotNull; 9 | 10 | import com.nisovin.magicspells.spells.targeted.OrbitSpell; 11 | import com.nisovin.magicspells.spells.targeted.cleanse.util.SpellCleanser; 12 | 13 | public class OrbitSpellCleanser extends SpellCleanser { 14 | 15 | @Override 16 | protected @NotNull String getPrefix() { 17 | return "orbit"; 18 | } 19 | 20 | @Override 21 | protected @NotNull Class getSpellClass() { 22 | return OrbitSpell.class; 23 | } 24 | 25 | @Override 26 | protected @NotNull BiPredicate getIsActive() { 27 | return OrbitSpell::hasOrbit; 28 | } 29 | 30 | @Override 31 | protected @NotNull BiConsumer getCleanse() { 32 | return OrbitSpell::removeOrbits; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/spells/targeted/cleanse/SilenceSpellCleanser.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.spells.targeted.cleanse; 2 | 3 | import java.util.function.BiConsumer; 4 | import java.util.function.BiPredicate; 5 | 6 | import org.bukkit.entity.LivingEntity; 7 | 8 | import org.jetbrains.annotations.NotNull; 9 | 10 | import com.nisovin.magicspells.spells.targeted.SilenceSpell; 11 | import com.nisovin.magicspells.spells.targeted.cleanse.util.SpellCleanser; 12 | 13 | public class SilenceSpellCleanser extends SpellCleanser { 14 | 15 | @Override 16 | protected @NotNull String getPrefix() { 17 | return "silence"; 18 | } 19 | 20 | @Override 21 | protected @NotNull Class getSpellClass() { 22 | return SilenceSpell.class; 23 | } 24 | 25 | @Override 26 | protected @NotNull BiPredicate getIsActive() { 27 | return SilenceSpell::isSilenced; 28 | } 29 | 30 | @Override 31 | protected @NotNull BiConsumer getCleanse() { 32 | return SilenceSpell::removeSilence; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/spells/targeted/cleanse/StunSpellCleanser.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.spells.targeted.cleanse; 2 | 3 | import java.util.function.BiConsumer; 4 | import java.util.function.BiPredicate; 5 | 6 | import org.bukkit.entity.LivingEntity; 7 | 8 | import org.jetbrains.annotations.NotNull; 9 | 10 | import com.nisovin.magicspells.spells.targeted.StunSpell; 11 | import com.nisovin.magicspells.spells.targeted.cleanse.util.SpellCleanser; 12 | 13 | public class StunSpellCleanser extends SpellCleanser { 14 | 15 | @Override 16 | protected @NotNull String getPrefix() { 17 | return "stun"; 18 | } 19 | 20 | @Override 21 | protected @NotNull Class getSpellClass() { 22 | return StunSpell.class; 23 | } 24 | 25 | @Override 26 | protected @NotNull BiPredicate getIsActive() { 27 | return StunSpell::isStunned; 28 | } 29 | 30 | @Override 31 | protected @NotNull BiConsumer getCleanse() { 32 | return StunSpell::removeStun; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/spells/targeted/cleanse/TotemSpellCleanser.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.spells.targeted.cleanse; 2 | 3 | import java.util.function.BiConsumer; 4 | import java.util.function.BiPredicate; 5 | 6 | import org.bukkit.entity.LivingEntity; 7 | 8 | import org.jetbrains.annotations.NotNull; 9 | 10 | import com.nisovin.magicspells.spells.targeted.TotemSpell; 11 | import com.nisovin.magicspells.spells.targeted.cleanse.util.SpellCleanser; 12 | 13 | public class TotemSpellCleanser extends SpellCleanser { 14 | 15 | @Override 16 | protected @NotNull String getPrefix() { 17 | return "totem"; 18 | } 19 | 20 | @Override 21 | protected @NotNull Class getSpellClass() { 22 | return TotemSpell.class; 23 | } 24 | 25 | @Override 26 | protected @NotNull BiPredicate getIsActive() { 27 | return TotemSpell::hasTotem; 28 | } 29 | 30 | @Override 31 | protected @NotNull BiConsumer getCleanse() { 32 | return TotemSpell::removeTotems; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/spells/targeted/cleanse/util/Cleanser.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.spells.targeted.cleanse.util; 2 | 3 | import org.bukkit.entity.LivingEntity; 4 | 5 | import org.jetbrains.annotations.NotNull; 6 | 7 | public interface Cleanser { 8 | 9 | boolean add(@NotNull String string); 10 | 11 | boolean isAnyActive(@NotNull LivingEntity entity); 12 | 13 | void cleanse(@NotNull LivingEntity entity); 14 | 15 | } 16 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/spells/targeted/cleanse/util/Cleansers.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.spells.targeted.cleanse.util; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | 5 | import com.nisovin.magicspells.MagicSpells; 6 | 7 | /** 8 | * @deprecated See {@link MagicSpells#getCleanserManager()} 9 | */ 10 | @Deprecated(forRemoval = true) 11 | public class Cleansers { 12 | 13 | private Cleansers() {} 14 | 15 | /** 16 | * @deprecated See {@link MagicSpells#getCleanserManager()} and {@link CleanserManager#addCleanser(Class)} 17 | */ 18 | @Deprecated(forRemoval = true) 19 | public static void addCleanserClass(@NotNull Class clazz) { 20 | MagicSpells.getCleanserManager().addCleanser(clazz); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/storage/StorageHandler.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.storage; 2 | 3 | import com.nisovin.magicspells.Spellbook; 4 | import com.nisovin.magicspells.MagicSpells; 5 | 6 | public abstract class StorageHandler { 7 | 8 | protected MagicSpells plugin; 9 | 10 | public StorageHandler(MagicSpells plugin) { 11 | this.plugin = plugin; 12 | } 13 | 14 | public abstract void initialize(); 15 | 16 | public abstract void load(Spellbook spellbook); 17 | 18 | public abstract void save(Spellbook spellbook); 19 | 20 | public abstract void disable(); 21 | 22 | } 23 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/storage/types/DatabaseStorage.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.storage.types; 2 | 3 | import com.nisovin.magicspells.Spellbook; 4 | import com.nisovin.magicspells.MagicSpells; 5 | import com.nisovin.magicspells.storage.Database; 6 | import com.nisovin.magicspells.storage.StorageHandler; 7 | 8 | public class DatabaseStorage extends StorageHandler { 9 | 10 | private final Database database; 11 | 12 | public DatabaseStorage(MagicSpells plugin, Database database) { 13 | super(plugin); 14 | this.database = database; 15 | } 16 | 17 | @Override 18 | public void initialize() { 19 | database.initialize(); 20 | } 21 | 22 | @Override 23 | public void load(Spellbook spellbook) { 24 | database.load(spellbook); 25 | database.getConnection(); 26 | } 27 | 28 | @Override 29 | public void save(Spellbook spellbook) { 30 | database.save(spellbook); 31 | } 32 | 33 | @Override 34 | public void disable() { 35 | database.disable(); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/util/Angle.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.util; 2 | 3 | /** 4 | * Represents an angle that can be applied to a reference angle. 5 | */ 6 | public record Angle(float angle, boolean relative) { 7 | 8 | public static final Angle DEFAULT = new Angle(0, true); 9 | 10 | /** 11 | * Applies this angle to a reference angle. 12 | * 13 | * @param angle the reference angle 14 | * @return the modified angle 15 | */ 16 | public float apply(final float angle) { 17 | return this.relative ? this.angle + angle : this.angle; 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/util/BooleanUtils.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.util; 2 | 3 | import java.util.Set; 4 | import java.util.HashSet; 5 | 6 | public class BooleanUtils { 7 | 8 | private static Set yesStrings; 9 | private static Set noStrings; 10 | static { 11 | yesStrings = new HashSet<>(); 12 | noStrings = new HashSet<>(); 13 | 14 | yesStrings.add("yes"); 15 | yesStrings.add("true"); 16 | 17 | noStrings.add("no"); 18 | noStrings.add("false"); 19 | } 20 | 21 | public static boolean isYes(String toCheck) { 22 | return yesStrings.contains(toCheck.trim().toLowerCase()); 23 | } 24 | 25 | public static boolean isNo(String toCheck) { 26 | return noStrings.contains(toCheck.trim().toLowerCase()); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/util/CastResult.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.util; 2 | 3 | import com.nisovin.magicspells.Spell.PostCastAction; 4 | 5 | public record CastResult(PostCastAction action, SpellData data) { 6 | } 7 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/util/DependsOn.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.util; 2 | 3 | import java.lang.annotation.Target; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.ElementType; 6 | import java.lang.annotation.RetentionPolicy; 7 | 8 | /** 9 | * Value may be an array of plugin names the annotated class might check 10 | * to see if they are enabled before allowing further processing. 11 | */ 12 | @Retention(RetentionPolicy.RUNTIME) 13 | @Target(ElementType.TYPE) 14 | public @interface DependsOn { 15 | 16 | String[] value(); 17 | 18 | } 19 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/util/DeprecationNotice.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.util; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | import org.jetbrains.annotations.Nullable; 5 | 6 | public record DeprecationNotice(@NotNull String reason, @NotNull String replacement, @Nullable String context) { 7 | 8 | public DeprecationNotice(@NotNull String reason, @NotNull String replacement) { 9 | this(reason, replacement, null); 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/util/MagicConversationPrefix.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.util; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | 5 | import org.bukkit.conversations.ConversationPrefix; 6 | import org.bukkit.conversations.ConversationContext; 7 | 8 | public class MagicConversationPrefix implements ConversationPrefix { 9 | 10 | private String prefix; 11 | 12 | public MagicConversationPrefix(String prefix) { 13 | this.prefix = prefix; 14 | } 15 | 16 | @Override 17 | @NotNull 18 | public String getPrefix(@NotNull ConversationContext paramConversationContext) { 19 | return prefix; 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/util/ModifierResult.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.util; 2 | 3 | public record ModifierResult(SpellData data, boolean check) { 4 | } 5 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/util/Name.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.util; 2 | 3 | import java.lang.annotation.Target; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.ElementType; 6 | import java.lang.annotation.RetentionPolicy; 7 | 8 | import org.intellij.lang.annotations.Pattern; 9 | 10 | @Retention(RetentionPolicy.RUNTIME) 11 | @Target(ElementType.TYPE) 12 | public @interface Name { 13 | 14 | @Pattern("[a-z0-9_]+") 15 | String value(); 16 | 17 | } 18 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/util/OverridePriority.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.util; 2 | 3 | public @interface OverridePriority { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/util/RegexUtil.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.util; 2 | 3 | import java.util.regex.Pattern; 4 | 5 | public class RegexUtil { 6 | 7 | public static final Pattern DOUBLE_PATTERN = Pattern.compile("[\\x00-\\x20]*[+-]?(NaN|Infinity|((((\\d+)(\\.)?((\\d+)?)([eE][+-]?(\\d+))?)|(\\.(\\d+)([eE][+-]?(\\d+))?)|(((0[xX](\\p{XDigit}+)(\\.)?)|(0[xX](\\p{XDigit}+)?(\\.)(\\p{XDigit}+)))[pP][+-]?(\\d+)))[fFdD]?))[\\x00-\\x20]*"); 8 | 9 | public static final Pattern SIMPLE_INT_PATTERN = Pattern.compile("^\\d+$"); 10 | 11 | } 12 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/util/TargetInfo.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.util; 2 | 3 | public record TargetInfo(T target, SpellData spellData, boolean cancelled) { 4 | 5 | public boolean empty() { 6 | return target == null; 7 | } 8 | 9 | public boolean noTarget() { 10 | return cancelled || target == null; 11 | } 12 | 13 | @Deprecated 14 | public T getTarget() { 15 | return target; 16 | } 17 | 18 | @Deprecated 19 | public float getPower() { 20 | return spellData.power(); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/util/TimeUtil.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.util; 2 | 3 | public class TimeUtil { 4 | 5 | public static final int TICKS_PER_SECOND = 20; 6 | public static final long MILLISECONDS_PER_SECOND = 1000; 7 | public static final long SECONDS_PER_MINUTE = 60; 8 | public static final long MINUTES_PER_HOUR = 60; 9 | public static final long MILLISECONDS_PER_MINUTE = MILLISECONDS_PER_SECOND * SECONDS_PER_MINUTE; 10 | public static final long MILLISECONDS_PER_HOUR = MILLISECONDS_PER_MINUTE * MINUTES_PER_HOUR; 11 | public static final long HOURS_PER_DAY = 24; 12 | public static final long DAYS_PER_WEEK = 7; 13 | public static final long HOURS_PER_WEEK = HOURS_PER_DAY * DAYS_PER_WEEK; 14 | public static final int TICKS_PER_MINUTE = (int)(TICKS_PER_SECOND * SECONDS_PER_MINUTE); 15 | 16 | } 17 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/util/ValidTargetChecker.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.util; 2 | 3 | import org.bukkit.entity.LivingEntity; 4 | 5 | @FunctionalInterface 6 | public interface ValidTargetChecker { 7 | 8 | boolean isValidTarget(LivingEntity entity); 9 | 10 | } 11 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/util/ai/CustomGoals.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.util.ai; 2 | 3 | import com.nisovin.magicspells.MagicSpells; 4 | 5 | /** 6 | * @deprecated See {@link MagicSpells#getCustomGoalsManager()} 7 | */ 8 | @Deprecated(forRemoval = true) 9 | public class CustomGoals { 10 | 11 | /** 12 | * @deprecated See {@link MagicSpells#getCustomGoalsManager()} and {@link CustomGoalsManager#addGoal(Class)} 13 | */ 14 | @Deprecated(forRemoval = true) 15 | public static void addGoal(Class goal) { 16 | MagicSpells.getCustomGoalsManager().addGoal(goal); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/util/bounds/Space.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.util.bounds; 2 | 3 | import org.bukkit.Location; 4 | import org.bukkit.block.Block; 5 | import org.bukkit.entity.Entity; 6 | 7 | public interface Space { 8 | 9 | boolean contains(Location location); 10 | 11 | boolean contains(Entity entity); 12 | 13 | boolean contains(Block block); 14 | 15 | } 16 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/util/bounds/SpaceCombined.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.util.bounds; 2 | 3 | import org.bukkit.Location; 4 | import org.bukkit.block.Block; 5 | import org.bukkit.entity.Entity; 6 | 7 | import java.util.Arrays; 8 | import java.util.Collection; 9 | import java.util.LinkedList; 10 | 11 | public class SpaceCombined extends LinkedList implements Space { 12 | 13 | public SpaceCombined(Space... spaces) { 14 | this(Arrays.asList(spaces)); 15 | } 16 | 17 | public SpaceCombined(Collection spaces) { 18 | super(spaces); 19 | } 20 | 21 | @Override 22 | public boolean contains(Location location) { 23 | return stream().anyMatch(space -> space.contains(location)); 24 | } 25 | 26 | @Override 27 | public boolean contains(Entity entity) { 28 | return stream().anyMatch(space -> space.contains(entity)); 29 | } 30 | 31 | @Override 32 | public boolean contains(Block block) { 33 | return stream().anyMatch(space -> space.contains(block)); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/util/compat/DummyExemptionAssistant.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.util.compat; 2 | 3 | import java.util.Collection; 4 | import java.util.function.Supplier; 5 | 6 | import org.bukkit.entity.Player; 7 | 8 | public class DummyExemptionAssistant implements ExemptionAssistant { 9 | 10 | @Override 11 | public T exemptRunnable(Supplier runnable, Player player, Collection nodes) { 12 | return runnable.get(); 13 | } 14 | 15 | @Override 16 | public Collection optimizeNodes(Object[] nodes) { 17 | return null; 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/util/compat/EventUtil.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.util.compat; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.event.Event; 5 | import org.bukkit.plugin.Plugin; 6 | import org.bukkit.event.Listener; 7 | 8 | import com.nisovin.magicspells.MagicSpells; 9 | 10 | // TODO add a utility to wrap operations in anticheat systems exemption 11 | public class EventUtil { 12 | 13 | public static void call(Event event) { 14 | Bukkit.getPluginManager().callEvent(event); 15 | } 16 | 17 | public static void register(Listener listener, Plugin plugin) { 18 | Bukkit.getPluginManager().registerEvents(listener, plugin); 19 | } 20 | 21 | public static void register(Listener listener) { 22 | register(listener, MagicSpells.plugin); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/util/compat/ExemptionAssistant.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.util.compat; 2 | 3 | import java.util.Collection; 4 | import java.util.Collections; 5 | import java.util.function.Supplier; 6 | 7 | import org.bukkit.entity.Player; 8 | 9 | public interface ExemptionAssistant { 10 | 11 | // The node objects should be the optimized nodes from optimizeNodes 12 | T exemptRunnable(Supplier runnable, Player player, Collection nodes); 13 | 14 | Collection optimizeNodes(Object[] nodes); 15 | 16 | // There should be access to various sets of exemption nodes for common actions through implementations of this interface 17 | default Collection getPainExemptions() { return Collections.emptySet(); } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/util/config/ConfigData.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.util.config; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | import org.jetbrains.annotations.Nullable; 5 | 6 | import com.nisovin.magicspells.util.SpellData; 7 | 8 | public interface ConfigData { 9 | 10 | T get(@NotNull SpellData data); 11 | 12 | default T get() { 13 | return get(SpellData.NULL); 14 | } 15 | 16 | default T getOr(@NotNull SpellData data, @Nullable T fallback) { 17 | T value = get(data); 18 | return value == null ? fallback : value; 19 | } 20 | 21 | default ConfigData orDefault(@NotNull ConfigData def) { 22 | return data -> { 23 | T value = get(data); 24 | return value != null ? value : def.get(data); 25 | }; 26 | } 27 | 28 | default boolean isConstant() { 29 | return true; 30 | } 31 | 32 | default boolean isNull() { 33 | return isConstant() && get() == null; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/util/config/VariableConfigData.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.util.config; 2 | 3 | public interface VariableConfigData extends ConfigData { 4 | 5 | @Override 6 | default boolean isConstant() { 7 | return false; 8 | } 9 | 10 | } 11 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/util/itemreader/alternative/ItemConfigTransformer.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.util.itemreader.alternative; 2 | 3 | import org.bukkit.inventory.ItemStack; 4 | import org.bukkit.configuration.ConfigurationSection; 5 | 6 | public interface ItemConfigTransformer { 7 | 8 | // Deserialize this section 9 | ItemStack deserialize(ConfigurationSection section); 10 | 11 | ConfigurationSection serialize(ItemStack itemStack); 12 | 13 | String getReaderKey(); 14 | 15 | } 16 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/util/itemreader/alternative/SpigotReader.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.util.itemreader.alternative; 2 | 3 | import org.bukkit.inventory.ItemStack; 4 | import org.bukkit.configuration.ConfigurationSection; 5 | import org.bukkit.configuration.file.YamlConfiguration; 6 | 7 | public class SpigotReader implements ItemConfigTransformer { 8 | 9 | private static final String READER_KEY = "external::spigot"; 10 | private static final String DATA_KEY = "data"; 11 | 12 | @Override 13 | public ItemStack deserialize(ConfigurationSection section) { 14 | if (section == null) return null; 15 | return section.getItemStack(DATA_KEY); 16 | } 17 | 18 | @Override 19 | public ConfigurationSection serialize(ItemStack itemStack) { 20 | YamlConfiguration configuration = new YamlConfiguration(); 21 | configuration.set(DATA_KEY, itemStack); 22 | return configuration; 23 | } 24 | 25 | @Override 26 | public String getReaderKey() { 27 | return READER_KEY; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/util/magicitems/MagicItem.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.util.magicitems; 2 | 3 | import org.bukkit.inventory.ItemStack; 4 | 5 | public class MagicItem { 6 | 7 | private ItemStack itemStack; 8 | private MagicItemData magicItemData; 9 | 10 | public MagicItem(ItemStack itemStack, MagicItemData magicItemData) { 11 | this.itemStack = itemStack; 12 | this.magicItemData = magicItemData; 13 | } 14 | 15 | public ItemStack getItemStack() { 16 | return itemStack; 17 | } 18 | 19 | public MagicItemData getMagicItemData() { 20 | return magicItemData; 21 | } 22 | 23 | public void setItemStack(ItemStack itemStack) { 24 | this.itemStack = itemStack; 25 | } 26 | 27 | public void setMagicItemData(MagicItemData magicItemData) { 28 | this.magicItemData = magicItemData; 29 | } 30 | 31 | @Override 32 | public MagicItem clone() { 33 | return new MagicItem(itemStack.clone(), magicItemData.clone()); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/util/messagelistener/MessageListener.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.util.messagelistener; 2 | 3 | import org.bukkit.entity.Player; 4 | 5 | public interface MessageListener { 6 | 7 | void addPlayer(Player player, ListenerData data); 8 | 9 | void removePlayer(Player player); 10 | 11 | void turnOff(); 12 | 13 | record ListenerData(boolean blockChatOutput, String strBlockedOutput, String storeChatOutput) {} 14 | 15 | } 16 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/util/messagelistener/MessageListenerFactory.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.util.messagelistener; 2 | 3 | import org.bukkit.Bukkit; 4 | 5 | import com.nisovin.magicspells.util.messagelistener.listeners.*; 6 | 7 | public class MessageListenerFactory { 8 | 9 | private MessageListenerFactory() {} 10 | 11 | public static MessageListener create() { 12 | boolean hasProtocolLib = Bukkit.getPluginManager().isPluginEnabled("ProtocolLib"); 13 | if (hasProtocolLib) return new ProtocolLibListener(); 14 | else return new ConversationBlocker(); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/util/projectile/ProjectileManagerArrow.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.util.projectile; 2 | 3 | import org.bukkit.entity.Arrow; 4 | import org.bukkit.entity.Projectile; 5 | 6 | public class ProjectileManagerArrow extends ProjectileManager { 7 | 8 | @Override 9 | public Class getProjectileClass() { 10 | return Arrow.class; 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/util/projectile/ProjectileManagerDragonFireball.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.util.projectile; 2 | 3 | import org.bukkit.entity.Projectile; 4 | import org.bukkit.entity.DragonFireball; 5 | 6 | public class ProjectileManagerDragonFireball extends ProjectileManager { 7 | 8 | @Override 9 | public Class getProjectileClass() { 10 | return DragonFireball.class; 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/util/projectile/ProjectileManagerEgg.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.util.projectile; 2 | 3 | import org.bukkit.entity.Egg; 4 | import org.bukkit.entity.Projectile; 5 | 6 | public class ProjectileManagerEgg extends ProjectileManager { 7 | 8 | @Override 9 | public Class getProjectileClass() { 10 | return Egg.class; 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/util/projectile/ProjectileManagerEnderPearl.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.util.projectile; 2 | 3 | import org.bukkit.entity.EnderPearl; 4 | import org.bukkit.entity.Projectile; 5 | 6 | public class ProjectileManagerEnderPearl extends ProjectileManager { 7 | 8 | @Override 9 | public Class getProjectileClass() { 10 | return EnderPearl.class; 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/util/projectile/ProjectileManagerFireball.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.util.projectile; 2 | 3 | import org.bukkit.entity.Fireball; 4 | import org.bukkit.entity.Projectile; 5 | 6 | public class ProjectileManagerFireball extends ProjectileManager { 7 | 8 | @Override 9 | public Class getProjectileClass() { 10 | return Fireball.class; 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/util/projectile/ProjectileManagerFishHook.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.util.projectile; 2 | 3 | import org.bukkit.entity.FishHook; 4 | import org.bukkit.entity.Projectile; 5 | 6 | public class ProjectileManagerFishHook extends ProjectileManager { 7 | 8 | @Override 9 | public Class getProjectileClass() { 10 | return FishHook.class; 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/util/projectile/ProjectileManagerLargeFireball.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.util.projectile; 2 | 3 | import org.bukkit.entity.Projectile; 4 | import org.bukkit.entity.LargeFireball; 5 | 6 | public class ProjectileManagerLargeFireball extends ProjectileManager { 7 | 8 | @Override 9 | public Class getProjectileClass() { 10 | return LargeFireball.class; 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/util/projectile/ProjectileManagerLingeringPotion.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.util.projectile; 2 | 3 | import org.bukkit.Material; 4 | import org.bukkit.inventory.ItemStack; 5 | 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | public class ProjectileManagerLingeringPotion extends ProjectileManagerThrownPotion { 9 | 10 | private static final ItemStack POTION = new ItemStack(Material.LINGERING_POTION); 11 | 12 | @NotNull 13 | @Override 14 | public ItemStack getItem() { 15 | return POTION; 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/util/projectile/ProjectileManagerLlamaSpit.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.util.projectile; 2 | 3 | import org.bukkit.entity.LlamaSpit; 4 | import org.bukkit.entity.Projectile; 5 | 6 | public class ProjectileManagerLlamaSpit extends ProjectileManager { 7 | 8 | @Override 9 | public Class getProjectileClass() { 10 | return LlamaSpit.class; 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/util/projectile/ProjectileManagerShulkerBullet.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.util.projectile; 2 | 3 | import org.bukkit.entity.Projectile; 4 | import org.bukkit.entity.ShulkerBullet; 5 | 6 | public class ProjectileManagerShulkerBullet extends ProjectileManager { 7 | 8 | @Override 9 | public Class getProjectileClass() { 10 | return ShulkerBullet.class; 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/util/projectile/ProjectileManagerSmallFireball.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.util.projectile; 2 | 3 | import org.bukkit.entity.Projectile; 4 | import org.bukkit.entity.SmallFireball; 5 | 6 | public class ProjectileManagerSmallFireball extends ProjectileManager { 7 | 8 | @Override 9 | public Class getProjectileClass() { 10 | return SmallFireball.class; 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/util/projectile/ProjectileManagerSnowball.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.util.projectile; 2 | 3 | import org.bukkit.entity.Snowball; 4 | import org.bukkit.entity.Projectile; 5 | 6 | public class ProjectileManagerSnowball extends ProjectileManager { 7 | 8 | @Override 9 | public Class getProjectileClass() { 10 | return Snowball.class; 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/util/projectile/ProjectileManagerSpectralArrow.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.util.projectile; 2 | 3 | import org.bukkit.entity.Projectile; 4 | import org.bukkit.entity.SpectralArrow; 5 | 6 | public class ProjectileManagerSpectralArrow extends ProjectileManager { 7 | 8 | @Override 9 | public Class getProjectileClass() { 10 | return SpectralArrow.class; 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/util/projectile/ProjectileManagerSplashPotion.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.util.projectile; 2 | 3 | import org.bukkit.Material; 4 | import org.bukkit.inventory.ItemStack; 5 | 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | public class ProjectileManagerSplashPotion extends ProjectileManagerThrownPotion { 9 | 10 | private static final ItemStack POTION = new ItemStack(Material.SPLASH_POTION); 11 | 12 | @NotNull 13 | @Override 14 | public ItemStack getItem() { 15 | return POTION; 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/util/projectile/ProjectileManagerThrownExpBottle.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.util.projectile; 2 | 3 | import org.bukkit.entity.Projectile; 4 | import org.bukkit.entity.ThrownExpBottle; 5 | 6 | public class ProjectileManagerThrownExpBottle extends ProjectileManager { 7 | 8 | @Override 9 | public Class getProjectileClass() { 10 | return ThrownExpBottle.class; 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/util/projectile/ProjectileManagerThrownPotion.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.util.projectile; 2 | 3 | import org.bukkit.Material; 4 | import org.bukkit.entity.Projectile; 5 | import org.bukkit.entity.ThrownPotion; 6 | import org.bukkit.inventory.ItemStack; 7 | 8 | import org.jetbrains.annotations.NotNull; 9 | 10 | public class ProjectileManagerThrownPotion extends ProjectileManager { 11 | 12 | private static final ItemStack POTION = new ItemStack(Material.POTION); 13 | 14 | @Override 15 | public Class getProjectileClass() { 16 | return ThrownPotion.class; 17 | } 18 | 19 | @NotNull 20 | public ItemStack getItem() { 21 | return POTION; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/util/projectile/ProjectileManagerTrident.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.util.projectile; 2 | 3 | import org.bukkit.entity.Trident; 4 | import org.bukkit.entity.Projectile; 5 | 6 | public class ProjectileManagerTrident extends ProjectileManager { 7 | 8 | @Override 9 | public Class getProjectileClass() { 10 | return Trident.class; 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/util/projectile/ProjectileManagerWitherSkull.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.util.projectile; 2 | 3 | import org.bukkit.entity.Projectile; 4 | import org.bukkit.entity.WitherSkull; 5 | 6 | public class ProjectileManagerWitherSkull extends ProjectileManager { 7 | 8 | @Override 9 | public Class getProjectileClass() { 10 | return WitherSkull.class; 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/util/prompt/MagicPromptResponder.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.util.prompt; 2 | 3 | import org.bukkit.entity.Player; 4 | import org.bukkit.conversations.Prompt; 5 | import org.bukkit.conversations.Conversable; 6 | import org.bukkit.conversations.ConversationContext; 7 | import org.bukkit.configuration.ConfigurationSection; 8 | 9 | import com.nisovin.magicspells.MagicSpells; 10 | 11 | public class MagicPromptResponder { 12 | 13 | String variableName; 14 | 15 | public MagicPromptResponder(ConfigurationSection section) { 16 | variableName = section.getString("variable-name", null); 17 | } 18 | 19 | public Prompt acceptValidatedInput(ConversationContext paramConversationContext, String paramString) { 20 | String playerName = null; 21 | Conversable who = paramConversationContext.getForWhom(); 22 | if (who instanceof Player player) playerName = player.getName(); 23 | 24 | // Try to save response to a variable. 25 | MagicSpells.getVariableManager().set(variableName, playerName, paramString); 26 | 27 | return Prompt.END_OF_CONVERSATION; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/util/recipes/CustomRecipeType.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.util.recipes; 2 | 3 | import java.util.function.Function; 4 | 5 | import com.nisovin.magicspells.util.recipes.types.*; 6 | 7 | import org.bukkit.configuration.ConfigurationSection; 8 | 9 | public enum CustomRecipeType { 10 | 11 | STONECUTTING(CustomStonecuttingRecipe::new), 12 | FURNACE(CustomFurnaceRecipe::new), 13 | SMOKING(CustomSmokingRecipe::new), 14 | CAMPFIRE(CustomCampfireRecipe::new), 15 | BLASTING(CustomBlastingRecipe::new), 16 | SMITHING(CustomSmithingRecipe::new), 17 | SHAPELESS(CustomShapelessRecipe::new), 18 | SHAPED(CustomShapedRecipe::new), 19 | 20 | ; 21 | 22 | private final Function builder; 23 | 24 | CustomRecipeType(Function builder) { 25 | this.builder = builder; 26 | } 27 | 28 | public CustomRecipe newInstance(ConfigurationSection config) { 29 | return builder.apply(config); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/util/recipes/types/CustomBlastingRecipe.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.util.recipes.types; 2 | 3 | import org.bukkit.inventory.CookingRecipe; 4 | import org.bukkit.inventory.BlastingRecipe; 5 | import org.bukkit.configuration.ConfigurationSection; 6 | 7 | public class CustomBlastingRecipe extends CustomCookingRecipe { 8 | 9 | public CustomBlastingRecipe(ConfigurationSection config) { 10 | super(config); 11 | } 12 | 13 | @Override 14 | protected CookingRecipe buildCooking() { 15 | return new BlastingRecipe(namespaceKey, result, ingredient, experience, cookingTime); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/util/recipes/types/CustomCampfireRecipe.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.util.recipes.types; 2 | 3 | import org.bukkit.inventory.CookingRecipe; 4 | import org.bukkit.inventory.CampfireRecipe; 5 | import org.bukkit.configuration.ConfigurationSection; 6 | 7 | public class CustomCampfireRecipe extends CustomCookingRecipe { 8 | 9 | public CustomCampfireRecipe(ConfigurationSection config) { 10 | super(config); 11 | } 12 | 13 | @Override 14 | protected CookingRecipe buildCooking() { 15 | return new CampfireRecipe(namespaceKey, result, ingredient, experience, cookingTime); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/util/recipes/types/CustomFurnaceRecipe.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.util.recipes.types; 2 | 3 | import org.bukkit.inventory.CookingRecipe; 4 | import org.bukkit.inventory.FurnaceRecipe; 5 | import org.bukkit.configuration.ConfigurationSection; 6 | 7 | public class CustomFurnaceRecipe extends CustomCookingRecipe { 8 | 9 | public CustomFurnaceRecipe(ConfigurationSection config) { 10 | super(config); 11 | } 12 | 13 | @Override 14 | protected CookingRecipe buildCooking() { 15 | return new FurnaceRecipe(namespaceKey, result, ingredient, experience, cookingTime); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/util/recipes/types/CustomSmithingRecipe.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.util.recipes.types; 2 | 3 | import org.bukkit.inventory.Recipe; 4 | import org.bukkit.inventory.RecipeChoice; 5 | import org.bukkit.inventory.SmithingTransformRecipe; 6 | import org.bukkit.configuration.ConfigurationSection; 7 | 8 | import com.nisovin.magicspells.util.recipes.CustomRecipe; 9 | 10 | public class CustomSmithingRecipe extends CustomRecipe { 11 | 12 | private final RecipeChoice template; 13 | private final RecipeChoice base; 14 | private final RecipeChoice addition; 15 | private final boolean copyNbt; 16 | 17 | public CustomSmithingRecipe(ConfigurationSection config) { 18 | super(config); 19 | template = resolveRecipeChoice("template"); 20 | base = resolveRecipeChoice("base"); 21 | addition = resolveRecipeChoice("addition"); 22 | copyNbt = config.getBoolean("copyNbt", true); 23 | } 24 | 25 | @Override 26 | public Recipe build() { 27 | return new SmithingTransformRecipe(namespaceKey, result, template, base, addition, copyNbt); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/util/recipes/types/CustomSmokingRecipe.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.util.recipes.types; 2 | 3 | import org.bukkit.inventory.CookingRecipe; 4 | import org.bukkit.inventory.SmokingRecipe; 5 | import org.bukkit.configuration.ConfigurationSection; 6 | 7 | public class CustomSmokingRecipe extends CustomCookingRecipe { 8 | 9 | public CustomSmokingRecipe(ConfigurationSection config) { 10 | super(config); 11 | } 12 | 13 | @Override 14 | protected CookingRecipe buildCooking() { 15 | return new SmokingRecipe(namespaceKey, result, ingredient, experience, cookingTime); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/util/recipes/types/CustomStonecuttingRecipe.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.util.recipes.types; 2 | 3 | import org.bukkit.inventory.Recipe; 4 | import org.bukkit.inventory.RecipeChoice; 5 | import org.bukkit.inventory.StonecuttingRecipe; 6 | import org.bukkit.configuration.ConfigurationSection; 7 | 8 | import com.nisovin.magicspells.util.recipes.CustomRecipe; 9 | 10 | public class CustomStonecuttingRecipe extends CustomRecipe { 11 | 12 | private final RecipeChoice ingredient; 13 | 14 | public CustomStonecuttingRecipe(ConfigurationSection config) { 15 | super(config); 16 | ingredient = resolveRecipeChoice("ingredient"); 17 | } 18 | 19 | @Override 20 | public Recipe build() { 21 | StonecuttingRecipe recipe = new StonecuttingRecipe(namespaceKey, result, ingredient); 22 | recipe.setGroup(group); 23 | return recipe; 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/util/trackers/Tracker.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.util.trackers; 2 | 3 | public interface Tracker { 4 | 5 | void initialize(); 6 | 7 | void stop(); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/variables/meta/AbsorptionVariable.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.variables.meta; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.entity.Player; 5 | 6 | import com.nisovin.magicspells.variables.variabletypes.MetaVariable; 7 | 8 | public class AbsorptionVariable extends MetaVariable { 9 | 10 | @Override 11 | public double getValue(String p) { 12 | Player player = Bukkit.getPlayerExact(p); 13 | if (player == null) return 0D; 14 | return player.getAbsorptionAmount(); 15 | } 16 | 17 | @Override 18 | public void set(String p, double amount) { 19 | Player player = Bukkit.getPlayerExact(p); 20 | if (player == null) return; 21 | player.setAbsorptionAmount(amount); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/variables/meta/AltitudeVariable.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.variables.meta; 2 | 3 | import org.bukkit.World; 4 | import org.bukkit.Bukkit; 5 | import org.bukkit.Location; 6 | import org.bukkit.entity.Player; 7 | 8 | import com.nisovin.magicspells.variables.variabletypes.MetaVariable; 9 | 10 | public class AltitudeVariable extends MetaVariable { 11 | 12 | @Override 13 | public double getValue(String player) { 14 | Player p = Bukkit.getPlayerExact(player); 15 | if (p == null) return 0; 16 | World world = p.getWorld(); 17 | Location location = p.getLocation().clone().subtract(0,1,0); 18 | int x = location.getBlockX(); 19 | int y = location.getBlockY(); 20 | int z = location.getBlockZ(); 21 | 22 | // Try to avoid looping through block below the player. 23 | int highestPoint = world.getHighestBlockYAt(location); 24 | if (highestPoint < y) return y - highestPoint; 25 | 26 | for (int i = y; i > 0; i--) { 27 | if (world.getBlockAt(x, i, z).getType().isAir()) continue; 28 | return y - i; 29 | } 30 | return 0; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/variables/meta/AttackCooldownVariable.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.variables.meta; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.entity.Player; 5 | 6 | import com.nisovin.magicspells.variables.variabletypes.MetaVariable; 7 | 8 | public class AttackCooldownVariable extends MetaVariable { 9 | 10 | @Override 11 | public double getValue(String player) { 12 | Player p = Bukkit.getPlayerExact(player); 13 | return p == null ? 0 : p.getAttackCooldown(); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/variables/meta/AttributeVariable.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.variables.meta; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.entity.Player; 5 | import org.bukkit.attribute.Attribute; 6 | import org.bukkit.attribute.AttributeInstance; 7 | 8 | import com.nisovin.magicspells.variables.variabletypes.MetaVariable; 9 | 10 | public class AttributeVariable extends MetaVariable { 11 | 12 | private final Attribute attribute; 13 | 14 | public AttributeVariable(Attribute attribute) { 15 | super(); 16 | 17 | this.attribute = attribute; 18 | } 19 | 20 | @Override 21 | public double getValue(String player) { 22 | Player p = Bukkit.getPlayerExact(player); 23 | if (p == null) return 0D; 24 | 25 | AttributeInstance inst = p.getAttribute(attribute); 26 | if (inst == null) return 0D; 27 | 28 | return inst.getValue(); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/variables/meta/BedCoordXVariable.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.variables.meta; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.entity.Player; 5 | 6 | import com.nisovin.magicspells.variables.variabletypes.MetaVariable; 7 | 8 | public class BedCoordXVariable extends MetaVariable { 9 | 10 | @Override 11 | public double getValue(String player) { 12 | Player p = Bukkit.getPlayerExact(player); 13 | if (p == null || !p.isSleeping()) return 0D; 14 | return p.getBedLocation().getX(); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/variables/meta/BedCoordYVariable.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.variables.meta; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.entity.Player; 5 | 6 | import com.nisovin.magicspells.variables.variabletypes.MetaVariable; 7 | 8 | public class BedCoordYVariable extends MetaVariable { 9 | 10 | @Override 11 | public double getValue(String player) { 12 | Player p = Bukkit.getPlayerExact(player); 13 | if (p == null || !p.isSleeping()) return 0D; 14 | return p.getBedLocation().getY(); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/variables/meta/BedCoordZVariable.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.variables.meta; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.entity.Player; 5 | 6 | import com.nisovin.magicspells.variables.variabletypes.MetaVariable; 7 | 8 | public class BedCoordZVariable extends MetaVariable { 9 | 10 | @Override 11 | public double getValue(String player) { 12 | Player p = Bukkit.getPlayerExact(player); 13 | if (p == null || !p.isSleeping()) return 0D; 14 | return p.getBedLocation().getZ(); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/variables/meta/BodyYawVariable.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.variables.meta; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.entity.Player; 5 | 6 | import com.nisovin.magicspells.variables.variabletypes.MetaVariable; 7 | 8 | public class BodyYawVariable extends MetaVariable { 9 | 10 | @Override 11 | public double getValue(String player) { 12 | Player p = Bukkit.getPlayerExact(player); 13 | return p == null ? 0 : p.getBodyYaw(); 14 | } 15 | 16 | @Override 17 | public void set(String player, double amount) { 18 | Player p = Bukkit.getPlayerExact(player); 19 | if (p != null) p.setBodyYaw((float) amount); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/variables/meta/CompassTargetXVariable.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.variables.meta; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.Location; 5 | import org.bukkit.entity.Player; 6 | 7 | import com.nisovin.magicspells.variables.variabletypes.MetaVariable; 8 | 9 | public class CompassTargetXVariable extends MetaVariable { 10 | 11 | @Override 12 | public double getValue(String player) { 13 | Player p = Bukkit.getPlayerExact(player); 14 | if (p != null) return p.getCompassTarget().getX(); 15 | return 0D; 16 | } 17 | 18 | @Override 19 | public void set(String player, double amount) { 20 | Player p = Bukkit.getPlayerExact(player); 21 | if (p == null) return; 22 | 23 | Location to = p.getCompassTarget(); 24 | to.setX((float) amount); 25 | p.setCompassTarget(to); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/variables/meta/CompassTargetYVariable.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.variables.meta; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.Location; 5 | import org.bukkit.entity.Player; 6 | 7 | import com.nisovin.magicspells.variables.variabletypes.MetaVariable; 8 | 9 | public class CompassTargetYVariable extends MetaVariable { 10 | 11 | @Override 12 | public double getValue(String player) { 13 | Player p = Bukkit.getPlayerExact(player); 14 | if (p != null) return p.getCompassTarget().getY(); 15 | return 0D; 16 | } 17 | 18 | @Override 19 | public void set(String player, double amount) { 20 | Player p = Bukkit.getPlayerExact(player); 21 | if (p == null) return; 22 | 23 | Location to = p.getCompassTarget(); 24 | to.setY((float) amount); 25 | p.setCompassTarget(to); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/variables/meta/CompassTargetZVariable.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.variables.meta; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.Location; 5 | import org.bukkit.entity.Player; 6 | 7 | import com.nisovin.magicspells.variables.variabletypes.MetaVariable; 8 | 9 | public class CompassTargetZVariable extends MetaVariable { 10 | 11 | @Override 12 | public double getValue(String player) { 13 | Player p = Bukkit.getPlayerExact(player); 14 | if (p != null) return p.getCompassTarget().getZ(); 15 | return 0D; 16 | } 17 | 18 | @Override 19 | public void set(String player, double amount) { 20 | Player p = Bukkit.getPlayerExact(player); 21 | if (p == null) return; 22 | 23 | Location to = p.getCompassTarget(); 24 | to.setZ((float) amount); 25 | p.setCompassTarget(to); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/variables/meta/CoordPitchVariable.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.variables.meta; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.Location; 5 | import org.bukkit.entity.Player; 6 | import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; 7 | 8 | import com.nisovin.magicspells.variables.variabletypes.MetaVariable; 9 | 10 | public class CoordPitchVariable extends MetaVariable { 11 | 12 | @Override 13 | public double getValue(String player) { 14 | Player p = Bukkit.getPlayerExact(player); 15 | if (p != null) return p.getLocation().getPitch(); 16 | return 0D; 17 | } 18 | 19 | @Override 20 | public void set(String player, double amount) { 21 | Player p = Bukkit.getPlayerExact(player); 22 | if (p == null) return; 23 | 24 | Location to = p.getLocation(); 25 | to.setPitch((float) amount); 26 | p.teleport(to, TeleportCause.PLUGIN); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/variables/meta/CoordXVariable.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.variables.meta; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.Location; 5 | import org.bukkit.entity.Player; 6 | import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; 7 | 8 | import com.nisovin.magicspells.variables.variabletypes.MetaVariable; 9 | 10 | public class CoordXVariable extends MetaVariable { 11 | 12 | @Override 13 | public double getValue(String player) { 14 | Player p = Bukkit.getPlayerExact(player); 15 | if (p != null) return p.getLocation().getX(); 16 | return 0D; 17 | } 18 | 19 | @Override 20 | public void set(String player, double amount) { 21 | Player p = Bukkit.getPlayerExact(player); 22 | if (p == null) return; 23 | 24 | Location to = p.getLocation(); 25 | to.setX(amount); 26 | p.teleport(to, TeleportCause.PLUGIN); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/variables/meta/CoordYVariable.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.variables.meta; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.Location; 5 | import org.bukkit.entity.Player; 6 | import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; 7 | 8 | import com.nisovin.magicspells.variables.variabletypes.MetaVariable; 9 | 10 | public class CoordYVariable extends MetaVariable { 11 | 12 | @Override 13 | public double getValue(String player) { 14 | Player p = Bukkit.getPlayerExact(player); 15 | if (p != null) return p.getLocation().getY(); 16 | return 0D; 17 | } 18 | 19 | @Override 20 | public void set(String player, double amount) { 21 | Player p = Bukkit.getPlayerExact(player); 22 | if (p == null) return; 23 | 24 | Location to = p.getLocation(); 25 | to.setY(amount); 26 | p.teleport(to, TeleportCause.PLUGIN); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/variables/meta/CoordYawVariable.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.variables.meta; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.Location; 5 | import org.bukkit.entity.Player; 6 | import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; 7 | 8 | import com.nisovin.magicspells.variables.variabletypes.MetaVariable; 9 | 10 | public class CoordYawVariable extends MetaVariable { 11 | 12 | @Override 13 | public double getValue(String player) { 14 | Player p = Bukkit.getPlayerExact(player); 15 | if (p != null) return p.getLocation().getYaw(); 16 | return 0D; 17 | } 18 | 19 | @Override 20 | public void set(String player, double amount) { 21 | Player p = Bukkit.getPlayerExact(player); 22 | if (p == null) return; 23 | 24 | Location to = p.getLocation(); 25 | to.setYaw((float) amount); 26 | p.teleport(to, TeleportCause.PLUGIN); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/variables/meta/CoordZVariable.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.variables.meta; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.Location; 5 | import org.bukkit.entity.Player; 6 | import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; 7 | 8 | import com.nisovin.magicspells.variables.variabletypes.MetaVariable; 9 | 10 | public class CoordZVariable extends MetaVariable { 11 | 12 | @Override 13 | public double getValue(String player) { 14 | Player p = Bukkit.getPlayerExact(player); 15 | if (p != null) return p.getLocation().getZ(); 16 | return 0D; 17 | } 18 | 19 | @Override 20 | public void set(String player, double amount) { 21 | Player p = Bukkit.getPlayerExact(player); 22 | if (p == null) return; 23 | 24 | Location to = p.getLocation(); 25 | to.setZ(amount); 26 | p.teleport(to, TeleportCause.PLUGIN); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/variables/meta/CurrentHealthVariable.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.variables.meta; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.entity.Player; 5 | 6 | import com.nisovin.magicspells.util.Util; 7 | import com.nisovin.magicspells.util.SpellUtil; 8 | import com.nisovin.magicspells.variables.variabletypes.MetaVariable; 9 | 10 | public class CurrentHealthVariable extends MetaVariable { 11 | 12 | @Override 13 | public double getValue(String player) { 14 | Player p = Bukkit.getPlayerExact(player); 15 | if (p != null) return p.getHealth(); 16 | return 0D; 17 | } 18 | 19 | @Override 20 | public void set(String player, double amount) { 21 | Player p = Bukkit.getPlayerExact(player); 22 | if (p == null) return; 23 | 24 | double max = Util.getMaxHealth(p); 25 | if (amount < 0) amount = 0; 26 | if (amount > max) amount = max; 27 | 28 | p.setHealth(amount); 29 | SpellUtil.updateManaBar(p); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/variables/meta/CurrentTickVariable.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.variables.meta; 2 | 3 | import org.bukkit.Bukkit; 4 | 5 | import com.nisovin.magicspells.variables.variabletypes.MetaVariable; 6 | 7 | public class CurrentTickVariable extends MetaVariable { 8 | 9 | @Override 10 | public double getValue(String player) { 11 | return Bukkit.getCurrentTick(); 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/variables/meta/EntityIDVariable.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.variables.meta; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.entity.Player; 5 | 6 | import com.nisovin.magicspells.variables.variabletypes.MetaVariable; 7 | 8 | public class EntityIDVariable extends MetaVariable { 9 | 10 | @Override 11 | public double getValue(String player) { 12 | Player p = Bukkit.getPlayerExact(player); 13 | if (p != null) return p.getEntityId(); 14 | return 0; 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/variables/meta/ExhaustionVariable.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.variables.meta; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.entity.Player; 5 | 6 | import com.nisovin.magicspells.variables.variabletypes.MetaVariable; 7 | 8 | public class ExhaustionVariable extends MetaVariable { 9 | 10 | @Override 11 | public double getValue(String player) { 12 | Player p = Bukkit.getPlayerExact(player); 13 | if (p != null) return p.getExhaustion(); 14 | return 0; 15 | } 16 | 17 | @Override 18 | public void set(String player, double amount) { 19 | Player p = Bukkit.getPlayerExact(player); 20 | if (p != null) p.setExhaustion((float) amount); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/variables/meta/ExperienceLevelVariable.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.variables.meta; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.entity.Player; 5 | 6 | import com.nisovin.magicspells.variables.variabletypes.MetaVariable; 7 | 8 | public class ExperienceLevelVariable extends MetaVariable { 9 | 10 | @Override 11 | public double getValue(String player) { 12 | Player p = Bukkit.getPlayerExact(player); 13 | if (p != null) return p.getLevel(); 14 | return 0; 15 | } 16 | 17 | @Override 18 | public void set(String player, double amount) { 19 | Player p = Bukkit.getPlayerExact(player); 20 | if (p != null) p.setLevel((int) amount); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/variables/meta/ExperienceVariable.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.variables.meta; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.entity.Player; 5 | 6 | import com.nisovin.magicspells.variables.variabletypes.MetaVariable; 7 | 8 | public class ExperienceVariable extends MetaVariable { 9 | 10 | @Override 11 | public double getValue(String player) { 12 | Player p = Bukkit.getPlayerExact(player); 13 | if (p != null) return p.getExp(); 14 | return 0; 15 | } 16 | 17 | @Override 18 | public void set(String player, double amount) { 19 | Player p = Bukkit.getPlayerExact(player); 20 | if (p != null) p.setExp((int) amount); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/variables/meta/FallDistanceVariable.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.variables.meta; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.entity.Player; 5 | 6 | import com.nisovin.magicspells.variables.variabletypes.MetaVariable; 7 | 8 | public class FallDistanceVariable extends MetaVariable { 9 | 10 | @Override 11 | public double getValue(String player) { 12 | Player p = Bukkit.getPlayerExact(player); 13 | if (p != null) return p.getFallDistance(); 14 | return 0D; 15 | } 16 | 17 | @Override 18 | public void set(String player, double amount) { 19 | Player p = Bukkit.getPlayerExact(player); 20 | if (p != null) p.setFallDistance((float) amount); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/variables/meta/FireTicksVariable.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.variables.meta; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.entity.Player; 5 | 6 | import com.nisovin.magicspells.variables.variabletypes.MetaVariable; 7 | 8 | public class FireTicksVariable extends MetaVariable { 9 | 10 | @Override 11 | public double getValue(String player) { 12 | Player p = Bukkit.getPlayerExact(player); 13 | if (p != null) return p.getFireTicks(); 14 | return 0; 15 | } 16 | 17 | @Override 18 | public void set(String player, double amount) { 19 | Player p = Bukkit.getPlayerExact(player); 20 | if (p != null) p.setFireTicks((int) amount); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/variables/meta/FlySpeedVariable.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.variables.meta; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.entity.Player; 5 | 6 | import com.nisovin.magicspells.variables.variabletypes.MetaVariable; 7 | 8 | public class FlySpeedVariable extends MetaVariable { 9 | 10 | @Override 11 | public double getValue(String player) { 12 | Player p = Bukkit.getPlayerExact(player); 13 | if (p != null) return p.getFlySpeed(); 14 | return 0D; 15 | } 16 | 17 | @Override 18 | public void set(String player, double amount) { 19 | Player p = Bukkit.getPlayerExact(player); 20 | if (p != null) p.setFlySpeed((float) amount); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/variables/meta/FoodLevelVariable.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.variables.meta; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.entity.Player; 5 | 6 | import com.nisovin.magicspells.util.SpellUtil; 7 | import com.nisovin.magicspells.variables.variabletypes.MetaVariable; 8 | 9 | public class FoodLevelVariable extends MetaVariable { 10 | 11 | @Override 12 | public double getValue(String player) { 13 | Player p = Bukkit.getPlayerExact(player); 14 | if (p != null) return p.getFoodLevel(); 15 | return 0; 16 | } 17 | 18 | @Override 19 | public void set(String player, double amount) { 20 | Player p = Bukkit.getPlayerExact(player); 21 | if (p == null) return; 22 | 23 | p.setFoodLevel((int) amount); 24 | SpellUtil.updateManaBar(p); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/variables/meta/ForwardsMovementVariable.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.variables.meta; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.entity.Player; 5 | 6 | import com.nisovin.magicspells.variables.variabletypes.MetaVariable; 7 | 8 | public class ForwardsMovementVariable extends MetaVariable { 9 | 10 | @Override 11 | public double getValue(String p) { 12 | Player player = Bukkit.getPlayerExact(p); 13 | if (player == null) return 0D; 14 | return player.getForwardsMovement(); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/variables/meta/FreezeTicksVariable.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.variables.meta; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.entity.Player; 5 | 6 | import com.nisovin.magicspells.variables.variabletypes.MetaVariable; 7 | 8 | public class FreezeTicksVariable extends MetaVariable { 9 | 10 | @Override 11 | public double getValue(String player) { 12 | Player p = Bukkit.getPlayerExact(player); 13 | return p == null ? 0 : p.getFreezeTicks(); 14 | } 15 | 16 | @Override 17 | public void set(String player, double amount) { 18 | Player p = Bukkit.getPlayerExact(player); 19 | if (p != null) p.setFreezeTicks((int) amount); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/variables/meta/HealthScaleVariable.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.variables.meta; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.entity.Player; 5 | 6 | import com.nisovin.magicspells.util.SpellUtil; 7 | import com.nisovin.magicspells.variables.variabletypes.MetaVariable; 8 | 9 | public class HealthScaleVariable extends MetaVariable { 10 | 11 | @Override 12 | public double getValue(String player) { 13 | Player p = Bukkit.getPlayerExact(player); 14 | if (p != null) return p.getHealthScale(); 15 | return 0D; 16 | } 17 | 18 | @Override 19 | public void set(String player, double amount) { 20 | Player p = Bukkit.getPlayerExact(player); 21 | if (p == null) return; 22 | 23 | p.setHealthScale(amount); 24 | SpellUtil.updateManaBar(p); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/variables/meta/LastDamageVariable.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.variables.meta; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.entity.Player; 5 | 6 | import com.nisovin.magicspells.variables.variabletypes.MetaVariable; 7 | 8 | public class LastDamageVariable extends MetaVariable { 9 | 10 | @Override 11 | public double getValue(String player) { 12 | Player p = Bukkit.getPlayerExact(player); 13 | if (p != null) return p.getLastDamage(); 14 | return 0D; 15 | } 16 | 17 | @Override 18 | public void set(String player, double amount) { 19 | Player p = Bukkit.getPlayerExact(player); 20 | if (p != null) p.setLastDamage(amount); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/variables/meta/ManaRegenVariable.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.variables.meta; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.entity.Player; 5 | 6 | import com.nisovin.magicspells.MagicSpells; 7 | import com.nisovin.magicspells.mana.ManaHandler; 8 | import com.nisovin.magicspells.variables.variabletypes.MetaVariable; 9 | 10 | public class ManaRegenVariable extends MetaVariable { 11 | 12 | @Override 13 | public double getValue(String player) { 14 | ManaHandler handler = MagicSpells.getManaHandler(); 15 | if (handler == null) return 0d; 16 | 17 | Player p = Bukkit.getPlayerExact(player); 18 | if (p == null) return 0d; 19 | 20 | return handler.getRegenAmount(p); 21 | } 22 | 23 | @Override 24 | public void set(String player, double amount) { 25 | ManaHandler handler = MagicSpells.getManaHandler(); 26 | if (handler == null) return; 27 | 28 | Player p = Bukkit.getPlayerExact(player); 29 | if (p == null) return; 30 | 31 | handler.setRegenAmount(p, (int) amount); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/variables/meta/ManaVariable.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.variables.meta; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.entity.Player; 5 | 6 | import com.nisovin.magicspells.MagicSpells; 7 | import com.nisovin.magicspells.mana.ManaHandler; 8 | import com.nisovin.magicspells.mana.ManaChangeReason; 9 | import com.nisovin.magicspells.variables.variabletypes.MetaVariable; 10 | 11 | public class ManaVariable extends MetaVariable { 12 | 13 | @Override 14 | public double getValue(String player) { 15 | ManaHandler handler = MagicSpells.getManaHandler(); 16 | if (handler == null) return 0d; 17 | 18 | Player p = Bukkit.getPlayerExact(player); 19 | if (p == null) return 0d; 20 | 21 | return handler.getMana(p); 22 | } 23 | 24 | @Override 25 | public void set(String player, double amount) { 26 | ManaHandler handler = MagicSpells.getManaHandler(); 27 | if (handler == null) return; 28 | 29 | Player p = Bukkit.getPlayerExact(player); 30 | if (p == null) return; 31 | 32 | handler.setMana(p, (int) amount, ManaChangeReason.OTHER); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/variables/meta/MaxFireTicksVariable.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.variables.meta; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.entity.Player; 5 | 6 | import com.nisovin.magicspells.variables.variabletypes.MetaVariable; 7 | 8 | public class MaxFireTicksVariable extends MetaVariable { 9 | 10 | @Override 11 | public double getValue(String player) { 12 | Player p = Bukkit.getPlayerExact(player); 13 | return p == null ? 0 : p.getMaxFireTicks(); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/variables/meta/MaxFreezeTicksVariable.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.variables.meta; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.entity.Player; 5 | 6 | import com.nisovin.magicspells.variables.variabletypes.MetaVariable; 7 | 8 | public class MaxFreezeTicksVariable extends MetaVariable { 9 | 10 | @Override 11 | public double getValue(String player) { 12 | Player p = Bukkit.getPlayerExact(player); 13 | return p == null ? 0 : p.getMaxFreezeTicks(); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/variables/meta/MaxHealthVariable.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.variables.meta; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.entity.Player; 5 | 6 | import com.nisovin.magicspells.util.Util; 7 | import com.nisovin.magicspells.variables.variabletypes.MetaVariable; 8 | 9 | public class MaxHealthVariable extends MetaVariable { 10 | 11 | @Override 12 | public double getValue(String player) { 13 | Player p = Bukkit.getPlayerExact(player); 14 | if (p != null) return Util.getMaxHealth(p); 15 | return 0D; 16 | } 17 | 18 | @Override 19 | public void set(String player, double amount) { 20 | Player p = Bukkit.getPlayerExact(player); 21 | if (p != null) Util.setMaxHealth(p, amount); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/variables/meta/MaxManaVariable.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.variables.meta; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.entity.Player; 5 | 6 | import com.nisovin.magicspells.MagicSpells; 7 | import com.nisovin.magicspells.mana.ManaHandler; 8 | import com.nisovin.magicspells.variables.variabletypes.MetaVariable; 9 | 10 | public class MaxManaVariable extends MetaVariable { 11 | 12 | @Override 13 | public double getValue(String player) { 14 | ManaHandler handler = MagicSpells.getManaHandler(); 15 | if (handler == null) return 0d; 16 | 17 | Player p = Bukkit.getPlayerExact(player); 18 | if (p == null) return 0d; 19 | 20 | return handler.getMaxMana(p); 21 | } 22 | 23 | @Override 24 | public void set(String player, double amount) { 25 | ManaHandler handler = MagicSpells.getManaHandler(); 26 | if (handler == null) return; 27 | 28 | Player p = Bukkit.getPlayerExact(player); 29 | if (p == null) return; 30 | 31 | handler.setMaxMana(p, (int) amount); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/variables/meta/MaximumAirVariable.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.variables.meta; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.entity.Player; 5 | 6 | import com.nisovin.magicspells.variables.variabletypes.MetaVariable; 7 | 8 | public class MaximumAirVariable extends MetaVariable { 9 | 10 | @Override 11 | public double getValue(String player) { 12 | Player p = Bukkit.getPlayerExact(player); 13 | if (p != null) return p.getMaximumAir(); 14 | return 0; 15 | } 16 | 17 | @Override 18 | public void set(String player, double amount) { 19 | Player p = Bukkit.getPlayerExact(player); 20 | if (p != null) p.setMaximumAir((int) amount); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/variables/meta/MaximumNoDamageTicksVariable.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.variables.meta; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.entity.Player; 5 | 6 | import com.nisovin.magicspells.variables.variabletypes.MetaVariable; 7 | 8 | public class MaximumNoDamageTicksVariable extends MetaVariable { 9 | 10 | @Override 11 | public double getValue(String player) { 12 | Player p = Bukkit.getPlayerExact(player); 13 | if (p != null) return p.getMaximumNoDamageTicks(); 14 | return 0; 15 | } 16 | 17 | @Override 18 | public void set(String player, double amount) { 19 | Player p = Bukkit.getPlayerExact(player); 20 | if (p != null) p.setMaximumNoDamageTicks((int) amount); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/variables/meta/NoDamageTicksVariable.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.variables.meta; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.entity.Player; 5 | 6 | import com.nisovin.magicspells.variables.variabletypes.MetaVariable; 7 | 8 | public class NoDamageTicksVariable extends MetaVariable { 9 | 10 | @Override 11 | public double getValue(String player) { 12 | Player p = Bukkit.getPlayerExact(player); 13 | if (p != null) return p.getNoDamageTicks(); 14 | return 0; 15 | } 16 | 17 | @Override 18 | public void set(String player, double amount) { 19 | Player p = Bukkit.getPlayerExact(player); 20 | if (p != null) p.setNoDamageTicks((int) amount); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/variables/meta/PlayersOnlineVariable.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.variables.meta; 2 | 3 | import org.bukkit.Bukkit; 4 | 5 | import com.nisovin.magicspells.variables.variabletypes.MetaVariable; 6 | 7 | public class PlayersOnlineVariable extends MetaVariable { 8 | 9 | @Override 10 | public double getValue(String player) { 11 | return Bukkit.getOnlinePlayers().size(); 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/variables/meta/RemainingAirVariable.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.variables.meta; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.entity.Player; 5 | 6 | import com.nisovin.magicspells.variables.variabletypes.MetaVariable; 7 | 8 | public class RemainingAirVariable extends MetaVariable { 9 | 10 | @Override 11 | public double getValue(String player) { 12 | Player p = Bukkit.getPlayerExact(player); 13 | if (p != null) return p.getRemainingAir(); 14 | return 0; 15 | } 16 | 17 | @Override 18 | public void set(String player, double amount) { 19 | Player p = Bukkit.getPlayerExact(player); 20 | if (p != null) p.setRemainingAir((int) amount); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/variables/meta/RespawnCoordXVariable.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.variables.meta; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.Location; 5 | import org.bukkit.entity.Player; 6 | 7 | import com.nisovin.magicspells.variables.variabletypes.MetaVariable; 8 | 9 | public class RespawnCoordXVariable extends MetaVariable { 10 | 11 | @Override 12 | public double getValue(String player) { 13 | Player p = Bukkit.getPlayerExact(player); 14 | if (p == null) return 0D; 15 | 16 | Location loc = p.getRespawnLocation(); 17 | if (loc != null) return loc.getX(); 18 | return p.getWorld().getSpawnLocation().getX(); 19 | } 20 | 21 | @Override 22 | public void set(String player, double amount) { 23 | Player p = Bukkit.getPlayerExact(player); 24 | if (p == null) return; 25 | 26 | Location to = p.getRespawnLocation(); 27 | if (to == null) return; 28 | to.setX(amount); 29 | p.setRespawnLocation(to, true); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/variables/meta/RespawnCoordYVariable.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.variables.meta; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.Location; 5 | import org.bukkit.entity.Player; 6 | 7 | import com.nisovin.magicspells.variables.variabletypes.MetaVariable; 8 | 9 | public class RespawnCoordYVariable extends MetaVariable { 10 | 11 | @Override 12 | public double getValue(String player) { 13 | Player p = Bukkit.getPlayerExact(player); 14 | if (p == null) return 0D; 15 | 16 | Location loc = p.getRespawnLocation(); 17 | if (loc != null) return loc.getY(); 18 | return p.getWorld().getSpawnLocation().getY(); 19 | } 20 | 21 | @Override 22 | public void set(String player, double amount) { 23 | Player p = Bukkit.getPlayerExact(player); 24 | if (p == null) return; 25 | 26 | Location to = p.getRespawnLocation(); 27 | if (to == null) return; 28 | to.setY(amount); 29 | p.setRespawnLocation(to, true); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/variables/meta/RespawnCoordZVariable.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.variables.meta; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.Location; 5 | import org.bukkit.entity.Player; 6 | 7 | import com.nisovin.magicspells.variables.variabletypes.MetaVariable; 8 | 9 | public class RespawnCoordZVariable extends MetaVariable { 10 | 11 | @Override 12 | public double getValue(String player) { 13 | Player p = Bukkit.getPlayerExact(player); 14 | if (p == null) return 0D; 15 | 16 | Location loc = p.getRespawnLocation(); 17 | if (loc != null) return loc.getZ(); 18 | return p.getWorld().getSpawnLocation().getZ(); 19 | } 20 | 21 | @Override 22 | public void set(String player, double amount) { 23 | Player p = Bukkit.getPlayerExact(player); 24 | if (p == null) return; 25 | 26 | Location to = p.getRespawnLocation(); 27 | if (to == null) return; 28 | to.setZ(amount); 29 | p.setRespawnLocation(to, true); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/variables/meta/SaturatedRegenRateVariable.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.variables.meta; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.entity.Player; 5 | 6 | import com.nisovin.magicspells.variables.variabletypes.MetaVariable; 7 | 8 | public class SaturatedRegenRateVariable extends MetaVariable { 9 | 10 | @Override 11 | public double getValue(String player) { 12 | Player p = Bukkit.getPlayerExact(player); 13 | if (p != null) return p.getSaturatedRegenRate(); 14 | return 0; 15 | } 16 | 17 | @Override 18 | public void set(String player, double amount) { 19 | Player p = Bukkit.getPlayerExact(player); 20 | if (p != null) p.setSaturatedRegenRate((int) amount); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/variables/meta/SaturationVariable.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.variables.meta; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.entity.Player; 5 | 6 | import com.nisovin.magicspells.variables.variabletypes.MetaVariable; 7 | 8 | public class SaturationVariable extends MetaVariable { 9 | 10 | @Override 11 | public double getValue(String player) { 12 | Player p = Bukkit.getPlayerExact(player); 13 | if (p != null) return p.getSaturation(); 14 | return 0D; 15 | } 16 | 17 | @Override 18 | public void set(String player, double amount) { 19 | Player p = Bukkit.getPlayerExact(player); 20 | if (p != null) p.setSaturation((float) amount); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/variables/meta/SidewaysMovementVariable.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.variables.meta; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.entity.Player; 5 | 6 | import com.nisovin.magicspells.variables.variabletypes.MetaVariable; 7 | 8 | public class SidewaysMovementVariable extends MetaVariable { 9 | 10 | @Override 11 | public double getValue(String p) { 12 | Player player = Bukkit.getPlayerExact(p); 13 | if (player == null) return 0D; 14 | return player.getSidewaysMovement(); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/variables/meta/SleepTicksVariable.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.variables.meta; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.entity.Player; 5 | 6 | import com.nisovin.magicspells.variables.variabletypes.MetaVariable; 7 | 8 | public class SleepTicksVariable extends MetaVariable { 9 | 10 | @Override 11 | public double getValue(String player) { 12 | Player p = Bukkit.getPlayerExact(player); 13 | if (p != null) return p.getSleepTicks(); 14 | return 0; 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/variables/meta/StarvationRateVariable.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.variables.meta; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.entity.Player; 5 | 6 | import com.nisovin.magicspells.variables.variabletypes.MetaVariable; 7 | 8 | public class StarvationRateVariable extends MetaVariable { 9 | 10 | @Override 11 | public double getValue(String player) { 12 | Player p = Bukkit.getPlayerExact(player); 13 | if (p != null) return p.getStarvationRate(); 14 | return 0; 15 | } 16 | 17 | @Override 18 | public void set(String player, double amount) { 19 | Player p = Bukkit.getPlayerExact(player); 20 | if (p != null) p.setStarvationRate((int) amount); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/variables/meta/TimestampDaysVariable.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.variables.meta; 2 | 3 | import java.time.Instant; 4 | 5 | import com.nisovin.magicspells.variables.variabletypes.MetaVariable; 6 | 7 | public class TimestampDaysVariable extends MetaVariable { 8 | 9 | @Override 10 | public double getValue(String player) { 11 | Instant instant = Instant.now(); 12 | long mins = instant.getEpochSecond(); 13 | return Math.floor(mins / 60F / 60F / 24F); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/variables/meta/TimestampHoursVariable.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.variables.meta; 2 | 3 | import java.time.Instant; 4 | 5 | import com.nisovin.magicspells.variables.variabletypes.MetaVariable; 6 | 7 | public class TimestampHoursVariable extends MetaVariable { 8 | 9 | @Override 10 | public double getValue(String player) { 11 | Instant instant = Instant.now(); 12 | long mins = instant.getEpochSecond(); 13 | return Math.floor(mins / 60F / 60F); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/variables/meta/TimestampMillisecondsVariable.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.variables.meta; 2 | 3 | import java.time.Instant; 4 | 5 | import com.nisovin.magicspells.variables.variabletypes.MetaVariable; 6 | 7 | public class TimestampMillisecondsVariable extends MetaVariable { 8 | 9 | @Override 10 | public double getValue(String player) { 11 | Instant instant = Instant.now(); 12 | return instant.toEpochMilli(); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/variables/meta/TimestampMinutesVariable.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.variables.meta; 2 | 3 | import java.time.Instant; 4 | 5 | import com.nisovin.magicspells.variables.variabletypes.MetaVariable; 6 | 7 | public class TimestampMinutesVariable extends MetaVariable { 8 | 9 | @Override 10 | public double getValue(String player) { 11 | Instant instant = Instant.now(); 12 | long mins = instant.getEpochSecond(); 13 | return Math.floor(mins / 60F); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/variables/meta/TimestampSecondsVariable.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.variables.meta; 2 | 3 | import java.time.Instant; 4 | 5 | import com.nisovin.magicspells.variables.variabletypes.MetaVariable; 6 | 7 | public class TimestampSecondsVariable extends MetaVariable { 8 | 9 | @Override 10 | public double getValue(String player) { 11 | Instant instant = Instant.now(); 12 | return instant.getEpochSecond(); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/variables/meta/UnsaturatedRegenRateVariable.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.variables.meta; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.entity.Player; 5 | 6 | import com.nisovin.magicspells.variables.variabletypes.MetaVariable; 7 | 8 | public class UnsaturatedRegenRateVariable extends MetaVariable { 9 | 10 | @Override 11 | public double getValue(String player) { 12 | Player p = Bukkit.getPlayerExact(player); 13 | if (p != null) return p.getUnsaturatedRegenRate(); 14 | return 0; 15 | } 16 | 17 | @Override 18 | public void set(String player, double amount) { 19 | Player p = Bukkit.getPlayerExact(player); 20 | if (p != null) p.setUnsaturatedRegenRate((int) amount); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/variables/meta/VelocityXVariable.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.variables.meta; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.util.Vector; 5 | import org.bukkit.entity.Player; 6 | 7 | import com.nisovin.magicspells.variables.variabletypes.MetaVariable; 8 | 9 | public class VelocityXVariable extends MetaVariable { 10 | 11 | @Override 12 | public double getValue(String player) { 13 | Player p = Bukkit.getPlayerExact(player); 14 | if (p != null) return p.getVelocity().getX(); 15 | return 0D; 16 | } 17 | 18 | @Override 19 | public void set(String player, double amount) { 20 | Player p = Bukkit.getPlayerExact(player); 21 | if (p == null) return; 22 | 23 | Vector velocity = p.getVelocity(); 24 | velocity.setX(amount); 25 | p.setVelocity(velocity); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/variables/meta/VelocityYVariable.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.variables.meta; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.util.Vector; 5 | import org.bukkit.entity.Player; 6 | 7 | import com.nisovin.magicspells.variables.variabletypes.MetaVariable; 8 | 9 | public class VelocityYVariable extends MetaVariable { 10 | 11 | @Override 12 | public double getValue(String player) { 13 | Player p = Bukkit.getPlayerExact(player); 14 | if (p != null) return p.getVelocity().getY(); 15 | return 0D; 16 | } 17 | 18 | @Override 19 | public void set(String player, double amount) { 20 | Player p = Bukkit.getPlayerExact(player); 21 | if (p == null) return; 22 | 23 | Vector velocity = p.getVelocity(); 24 | velocity.setY(amount); 25 | p.setVelocity(velocity); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/variables/meta/VelocityZVariable.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.variables.meta; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.util.Vector; 5 | import org.bukkit.entity.Player; 6 | 7 | import com.nisovin.magicspells.variables.variabletypes.MetaVariable; 8 | 9 | public class VelocityZVariable extends MetaVariable { 10 | 11 | @Override 12 | public double getValue(String player) { 13 | Player p = Bukkit.getPlayerExact(player); 14 | if (p != null) return p.getVelocity().getZ(); 15 | return 0D; 16 | } 17 | 18 | @Override 19 | public void set(String player, double amount) { 20 | Player p = Bukkit.getPlayerExact(player); 21 | if (p == null) return; 22 | 23 | Vector velocity = p.getVelocity(); 24 | velocity.setZ(amount); 25 | p.setVelocity(velocity); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/variables/meta/WalkSpeedVariable.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.variables.meta; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.entity.Player; 5 | 6 | import com.nisovin.magicspells.variables.variabletypes.MetaVariable; 7 | 8 | public class WalkSpeedVariable extends MetaVariable { 9 | 10 | @Override 11 | public double getValue(String player) { 12 | Player p = Bukkit.getPlayerExact(player); 13 | if (p != null) return p.getWalkSpeed(); 14 | return 0D; 15 | } 16 | 17 | @Override 18 | public void set(String player, double amount) { 19 | Player p = Bukkit.getPlayerExact(player); 20 | if (p != null) p.setWalkSpeed((float) amount); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/variables/variabletypes/GlobalVariable.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.variables.variabletypes; 2 | 3 | import com.nisovin.magicspells.util.Name; 4 | import com.nisovin.magicspells.variables.Variable; 5 | 6 | @Name("global") 7 | public class GlobalVariable extends Variable { 8 | 9 | private double value = 0; 10 | 11 | @Override 12 | protected void init() { 13 | value = defaultValue; 14 | } 15 | 16 | @Override 17 | public void set(String player, double amount) { 18 | if (amount > maxValue) amount = maxValue; 19 | else if (amount < minValue) amount = minValue; 20 | value = amount; 21 | } 22 | 23 | @Override 24 | public double getValue(String player) { 25 | return value; 26 | } 27 | 28 | @Override 29 | public void reset(String player) { 30 | value = defaultValue; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/variables/variabletypes/MetaVariable.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.variables.variabletypes; 2 | 3 | import com.nisovin.magicspells.variables.Variable; 4 | 5 | public abstract class MetaVariable extends Variable { 6 | 7 | public MetaVariable() { 8 | permanent = false; 9 | expBar = false; 10 | bossBarTitle = null; 11 | objective = null; 12 | minValue = Double.MIN_VALUE; 13 | } 14 | 15 | @Override 16 | protected void init() { 17 | permanent = false; 18 | } 19 | 20 | @Override 21 | public void set(String player, double amount) { 22 | // No op 23 | } 24 | 25 | @Override 26 | public void reset(String player) { 27 | // No op 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/variables/variabletypes/PlayerStringVariable.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.variables.variabletypes; 2 | 3 | import java.util.Map; 4 | import java.util.HashMap; 5 | 6 | import com.nisovin.magicspells.util.Name; 7 | 8 | import org.bukkit.configuration.ConfigurationSection; 9 | 10 | @Name("playerstring") 11 | public class PlayerStringVariable extends PlayerVariable { 12 | 13 | private final Map data; 14 | 15 | public PlayerStringVariable() { 16 | data = new HashMap<>(); 17 | } 18 | 19 | @Override 20 | public void loadExtraData(ConfigurationSection section) { 21 | super.loadExtraData(section); 22 | defaultStringValue = section.getString("default-value", ""); 23 | } 24 | 25 | @Override 26 | public String getStringValue(String player) { 27 | return data.getOrDefault(player, defaultStringValue); 28 | } 29 | 30 | @Override 31 | public void parseAndSet(String player, String textValue) { 32 | data.put(player, textValue); 33 | } 34 | 35 | @Override 36 | public void reset(String player) { 37 | data.remove(player); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/variables/variabletypes/PlayerVariable.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.variables.variabletypes; 2 | 3 | import java.util.Map; 4 | import java.util.HashMap; 5 | 6 | import com.nisovin.magicspells.util.Name; 7 | import com.nisovin.magicspells.variables.Variable; 8 | 9 | @Name("player") 10 | public class PlayerVariable extends Variable { 11 | 12 | private final Map map = new HashMap<>(); 13 | 14 | @Override 15 | public void set(String player, double amount) { 16 | if (amount > maxValue) amount = maxValue; 17 | else if (amount < minValue) amount = minValue; 18 | map.put(player, amount); 19 | if (objective == null) return; 20 | objective.getScore(player).setScore((int) amount); 21 | } 22 | 23 | @Override 24 | public double getValue(String player) { 25 | return map.getOrDefault(player, defaultValue); 26 | } 27 | 28 | @Override 29 | public void reset(String player) { 30 | map.remove(player); 31 | if (objective == null) return; 32 | objective.getScore(player).setScore((int) defaultValue); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/variables/variabletypes/SquaredDistanceToLocationVariable.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.variables.variabletypes; 2 | 3 | import org.bukkit.Location; 4 | 5 | import com.nisovin.magicspells.util.Name; 6 | 7 | @Name("squareddistancetolocation") 8 | public class SquaredDistanceToLocationVariable extends DistanceToLocationVariable { 9 | 10 | public SquaredDistanceToLocationVariable() { 11 | super(); 12 | } 13 | 14 | @Override 15 | protected double calculateReportedDistance(double multiplier, Location origin, Location target) { 16 | return target.distanceSquared(origin) * multiplier; 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /core/src/main/resources/defaults.yml: -------------------------------------------------------------------------------- 1 | # # You an specify default values for spell classes here. 2 | # # Create a configuration section with a spell class for key. The nodes of the 3 | # # section determine the default values for unspecified options for that spell. 4 | # # Example: 5 | # 6 | # # Defaults for all leap spells. 7 | # ".instant.LeapSpell": 8 | # rotation: 0 9 | # upward-velocity: 15 10 | # forward-velocity: 40 11 | # client-only: false 12 | # cancel-damage: true 13 | # add-velocity-instead: false 14 | # power-affects-velocity: true 15 | # 16 | # # You can also specify parent spell classes to apply options more broadly. 17 | # # Examples: 18 | # 19 | # # Defaults for all spells. 20 | # "com.nisovin.magicspells.Spell": 21 | # cooldown: 5 22 | # range: 6 23 | # 24 | # # Defaults for all buff spells. 25 | # ".BuffSpell": 26 | # duration: 20 27 | # toggle: false 28 | -------------------------------------------------------------------------------- /core/src/main/resources/plugin.yml: -------------------------------------------------------------------------------- 1 | name: MagicSpells 2 | main: com.nisovin.magicspells.MagicSpells 3 | version: $version 4 | authors: [nisovin, TheComputerGeek2, Chronoken, tonythemacaroni, JasperLorelai] 5 | website: "https://github.com/TheComputerGeek2/MagicSpells/" 6 | api-version: "1.21.4" 7 | softdepend: 8 | - GriefPrevention 9 | - Vault 10 | - ProtocolLib 11 | - WorldGuard 12 | - LibsDisguises 13 | - NoCheatPlus 14 | - PlaceholderAPI 15 | - XGlow 16 | - packetevents 17 | -------------------------------------------------------------------------------- /core/src/main/resources/zones.yml: -------------------------------------------------------------------------------- 1 | zone1: 2 | enabled: false 3 | world: world 4 | type: cuboid 5 | point1: -30,0,-30 6 | point2: 30,128,30 7 | message: An anti-magic aura makes your spell fizzle. 8 | allowed-spells: 9 | - list 10 | - help 11 | zone2: 12 | enabled: false 13 | world: world 14 | type: worldguard 15 | region: arena 16 | message: You cannot use that spell in the arena. 17 | disallowed-spells: 18 | - blink 19 | - gate 20 | - mark 21 | - recall 22 | -------------------------------------------------------------------------------- /factions/build.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | implementation project(":core") 3 | //implementation ":MassiveCore" 4 | //implementation ":Factions" 5 | } 6 | 7 | jar { 8 | archiveFileName = "MagicSpellsFactions.jar" 9 | } 10 | -------------------------------------------------------------------------------- /factions/src/main/java/com/nisovin/magicspells/factions/conditions/HasFactionCondition.java: -------------------------------------------------------------------------------- 1 | /* 2 | package com.nisovin.magicspells.factions.conditions; 3 | 4 | import org.bukkit.Location; 5 | import org.bukkit.entity.Player; 6 | import org.bukkit.entity.LivingEntity; 7 | 8 | import com.massivecraft.factions.entity.MPlayer; 9 | 10 | import com.nisovin.magicspells.castmodifiers.Condition; 11 | 12 | public class HasFactionCondition extends Condition { 13 | 14 | @Override 15 | public boolean initialize(String var) { 16 | return true; 17 | } 18 | 19 | @Override 20 | public boolean check(LivingEntity livingEntity) { 21 | return livingEntity != null && livingEntity instanceof Player && MPlayer.get(livingEntity).hasFaction(); 22 | } 23 | 24 | @Override 25 | public boolean check(LivingEntity livingEntity, LivingEntity target) { 26 | return target != null && target instanceof Player && MPlayer.get(target).hasFaction(); 27 | } 28 | 29 | @Override 30 | public boolean check(LivingEntity livingEntity, Location location) { 31 | return false; 32 | } 33 | 34 | } 35 | */ 36 | -------------------------------------------------------------------------------- /factions/src/main/resources/plugin.yml: -------------------------------------------------------------------------------- 1 | name: MagicSpellsFactions 2 | version: $version 3 | main: com.nisovin.magicspells.factions.MagicSpellsFactions 4 | depend: [ MagicSpells, Factions ] 5 | authors: [nisovin, TheComputerGeek2] 6 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | version = 4.0-Beta-17 2 | groupId = com.nisovin.magicspells 3 | 4 | org.gradle.parallel=true 5 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheComputerGeek2/MagicSpells/4296ac93f1b901d416a929ffb8a5823aecd45966/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip 4 | networkTimeout=10000 5 | validateDistributionUrl=true 6 | zipStoreBase=GRADLE_USER_HOME 7 | zipStorePath=wrapper/dists 8 | -------------------------------------------------------------------------------- /jitpack.yml: -------------------------------------------------------------------------------- 1 | jdk: 2 | - openjdk21 3 | -------------------------------------------------------------------------------- /memory/build.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | implementation project(":core") 3 | } 4 | 5 | jar { 6 | archiveFileName = "MagicSpellsMemory.jar" 7 | } 8 | -------------------------------------------------------------------------------- /memory/src/main/resources/config.yml: -------------------------------------------------------------------------------- 1 | str-out-of-memory: "You don't have enough memory to learn the %spell spell." 2 | str-memory-usage: "You have used %memory memory out of %total." 3 | max-memory-default: 10 4 | max-memory-perms: 5 | admin: 1000 6 | master: 20 7 | adept: 10 8 | novice: 5 -------------------------------------------------------------------------------- /memory/src/main/resources/plugin.yml: -------------------------------------------------------------------------------- 1 | name: MagicSpellsMemory 2 | version: $version 3 | main: com.nisovin.magicspells.memory.MagicSpellsMemory 4 | depend: [MagicSpells] 5 | commands: 6 | magicspellsmemory: 7 | description: Check your memory usage 8 | usage: / 9 | aliases: [memory,mem] 10 | permissions: 11 | magicspells.memory.checkothers: 12 | description: Check someone else's memory usage 13 | default: op 14 | -------------------------------------------------------------------------------- /nms/latest/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id "io.papermc.paperweight.userdev" 3 | } 4 | 5 | dependencies { 6 | paperweight.paperDevBundle("1.21.5-R0.1-SNAPSHOT") 7 | implementation project(":nms:shared") 8 | } 9 | -------------------------------------------------------------------------------- /nms/shared/build.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | implementation(group: "me.libraryaddict.disguises", name: "libsdisguises", version: "10.0.44-SNAPSHOT") { transitive = false } 3 | } 4 | -------------------------------------------------------------------------------- /nms/shared/src/main/java/com/nisovin/magicspells/util/glow/GlowManager.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.util.glow; 2 | 3 | import org.jetbrains.annotations.Range; 4 | import org.jetbrains.annotations.NotNull; 5 | 6 | import net.kyori.adventure.text.format.NamedTextColor; 7 | 8 | import org.bukkit.NamespacedKey; 9 | import org.bukkit.entity.Entity; 10 | import org.bukkit.entity.Player; 11 | 12 | public interface GlowManager { 13 | 14 | void load(); 15 | 16 | void unload(); 17 | 18 | void applyGlow(@NotNull Entity entity, @NotNull NamespacedKey key, @NotNull NamedTextColor color, int priority, @Range(from = 0, to = Integer.MAX_VALUE) int duration); 19 | 20 | void applyGlow(@NotNull Player player, @NotNull Entity entity, @NotNull NamespacedKey key, @NotNull NamedTextColor color, int priority, @Range(from = 0, to = Integer.MAX_VALUE) int duration); 21 | 22 | void removeGlow(@NotNull Entity entity, @NotNull NamespacedKey key); 23 | 24 | void removeGlow(@NotNull Player player, @NotNull Entity entity, @NotNull NamespacedKey key); 25 | 26 | } 27 | -------------------------------------------------------------------------------- /nms/shared/src/main/java/com/nisovin/magicspells/volatilecode/VolatileCodeHelper.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.volatilecode; 2 | 3 | import org.bukkit.event.Listener; 4 | import org.bukkit.configuration.file.YamlConfiguration; 5 | 6 | public interface VolatileCodeHelper { 7 | 8 | void error(String message); 9 | 10 | int scheduleDelayedTask(Runnable task, long delay); 11 | 12 | void cancelTask(int id); 13 | 14 | void registerEvents(Listener listener); 15 | 16 | YamlConfiguration getMainConfig(); 17 | 18 | } 19 | -------------------------------------------------------------------------------- /nms/v1_21_4/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id "io.papermc.paperweight.userdev" 3 | } 4 | 5 | dependencies { 6 | paperweight.paperDevBundle("1.21.4-R0.1-SNAPSHOT") 7 | implementation project(":nms:shared") 8 | } 9 | -------------------------------------------------------------------------------- /settings.gradle.kts: -------------------------------------------------------------------------------- 1 | rootProject.name = "MagicSpellsParent" 2 | 3 | include("core") 4 | include("factions") 5 | include("memory") 6 | include("shop") 7 | include("teams") 8 | include("towny") 9 | 10 | include(":nms:shared") 11 | include(":nms:latest") 12 | include(":nms:v1_21_4") 13 | 14 | pluginManagement { 15 | repositories { 16 | gradlePluginPortal() 17 | maven("https://repo.papermc.io/repository/maven-public/") 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /shop/build.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | implementation project(":core") 3 | implementation(group: "net.milkbowl.vault", name: "VaultAPI", version: "1.7") { transitive = false } 4 | } 5 | 6 | jar { 7 | archiveFileName = "MagicSpellsShop.jar" 8 | } 9 | 10 | publishing { 11 | publications { 12 | maven(MavenPublication) { 13 | from components.java 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /shop/src/main/java/com/nisovin/magicspells/shop/Perm.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.shop; 2 | 3 | import org.bukkit.permissions.Permissible; 4 | 5 | public enum Perm { 6 | 7 | CREATESIGNSHOP("magicspells.createsignshop") 8 | 9 | ; 10 | 11 | private final String node; 12 | public String getNode() { return this.node; } 13 | 14 | Perm(String node) { 15 | this.node = node; 16 | } 17 | 18 | public boolean has(Permissible permissible) { 19 | return permissible.hasPermission(this.node); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /shop/src/main/resources/config.yml: -------------------------------------------------------------------------------- 1 | ignore-other-plugins: false 2 | require-known-spell: true 3 | require-teach-perm: true 4 | 5 | currencies: 6 | money: "vault" 7 | levels: "levels" 8 | xp: "experience" 9 | gold: "266" 10 | cocoa: "351:3" 11 | 12 | first-line: [SPELL SHOP] 13 | str-already-known: You already know that spell. 14 | str-cant-afford: You cannot afford that spell. 15 | str-cant-learn: You are not able to buy that spell. 16 | str-purchased: You have purchased the %s spell. 17 | 18 | first-line-scroll: [SCROLL SHOP] 19 | scroll-spell-name: scroll 20 | scroll-item-type: 339 21 | str-cant-afford-scroll: You cannot afford that scroll. 22 | str-purchased-scroll: You have purchased a scroll for the %s spell (with %u uses). 23 | str-scroll-fail: You cannot purchase a scroll at this time. -------------------------------------------------------------------------------- /shop/src/main/resources/plugin.yml: -------------------------------------------------------------------------------- 1 | name: MagicSpellsShop 2 | version: $version 3 | main: com.nisovin.magicspells.shop.MagicSpellsShop 4 | author: nisovin 5 | depend: [MagicSpells] 6 | softdepend: [Vault] 7 | permissions: 8 | magicspells.createsignshop: 9 | description: Create a spell shop 10 | default: op 11 | -------------------------------------------------------------------------------- /teams/build.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | implementation project(":core") 3 | } 4 | 5 | jar { 6 | archiveFileName = "MagicSpellsTeams.jar" 7 | } 8 | -------------------------------------------------------------------------------- /teams/src/main/java/com/nisovin/magicspells/teams/ListTeamsSubCommand.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.teams; 2 | 3 | import java.util.Set; 4 | 5 | import org.bukkit.command.CommandSender; 6 | 7 | public class ListTeamsSubCommand implements TeamsSubCommand { 8 | 9 | private MagicSpellsTeams plugin; 10 | 11 | public ListTeamsSubCommand(MagicSpellsTeams plugin) { 12 | this.plugin = plugin; 13 | } 14 | 15 | @Override 16 | public boolean process(CommandSender sender, String[] args) { 17 | Set names = this.plugin.getTeamNames(); 18 | sender.sendMessage("Team Names"); 19 | for (String name: names) { 20 | sender.sendMessage(name); 21 | } 22 | return true; 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /teams/src/main/java/com/nisovin/magicspells/teams/TeamsSubCommand.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.teams; 2 | 3 | import org.bukkit.command.CommandSender; 4 | 5 | @FunctionalInterface 6 | public interface TeamsSubCommand { 7 | 8 | boolean process(CommandSender sender, String[] args); 9 | 10 | } 11 | -------------------------------------------------------------------------------- /teams/src/main/resources/config.yml: -------------------------------------------------------------------------------- 1 | use-cache: true 2 | clear-cache-on-death: false 3 | 4 | teams: 5 | admins: 6 | permission: "magicspells.team.admins" 7 | friendly-fire: false 8 | team1: 9 | permission: "magicspells.team.one" 10 | friendly-fire: false 11 | can-target: 12 | - team2 13 | team2: 14 | permission: "magicspells.team.two" 15 | friendly-fire: false 16 | cant-target: 17 | - admins -------------------------------------------------------------------------------- /teams/src/main/resources/plugin.yml: -------------------------------------------------------------------------------- 1 | name: MagicSpellsTeams 2 | version: $version 3 | main: com.nisovin.magicspells.teams.MagicSpellsTeams 4 | authors: [nisovin, TheComputerGeek2] 5 | depend: [MagicSpells] 6 | commands: 7 | magicspellsteams: 8 | usage: | 9 | / - makes a new team 10 | / list - lists the existing teams 11 | / - shows setup information about a team 12 | permission: magicspellsteams.manage 13 | description: Base command for team management. 14 | permissions: 15 | magicspellsteams.manage: 16 | default: op 17 | description: Manage teams from in game. 18 | -------------------------------------------------------------------------------- /towny/build.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | implementation project(":core") 3 | implementation(group: "com.palmergames.bukkit.towny", name: "towny", version: "0.100.1.0") { transitive = false } 4 | } 5 | 6 | jar { 7 | archiveFileName = "MagicSpellsTowny.jar" 8 | } 9 | -------------------------------------------------------------------------------- /towny/src/main/resources/config.yml: -------------------------------------------------------------------------------- 1 | disallowed-in-towns: 2 | - forcepush 3 | - fireball 4 | - lightning 5 | - explode 6 | - explosivearrow 7 | - phase 8 | - volley -------------------------------------------------------------------------------- /towny/src/main/resources/plugin.yml: -------------------------------------------------------------------------------- 1 | name: MagicSpellsTowny 2 | main: com.nisovin.magicspells.towny.MagicSpellsTowny 3 | version: $version 4 | author: nisovin 5 | depend: [MagicSpells,Towny] 6 | --------------------------------------------------------------------------------