├── jitpack.yml ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .gitignore ├── teams ├── build.gradle └── src │ └── main │ ├── java │ └── com │ │ └── nisovin │ │ └── magicspells │ │ └── teams │ │ ├── TeamsSubCommand.java │ │ └── ListTeamsSubCommand.java │ └── resources │ ├── config.yml │ └── plugin.yml ├── memory ├── build.gradle └── src │ └── main │ └── resources │ ├── config.yml │ └── plugin.yml ├── nms ├── shared │ ├── build.gradle │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── nisovin │ │ └── magicspells │ │ ├── volatilecode │ │ └── VolatileCodeHelper.java │ │ └── util │ │ └── glow │ │ └── GlowManager.java ├── latest │ └── build.gradle └── v1_21_10 │ └── build.gradle ├── towny ├── src │ └── main │ │ └── resources │ │ ├── config.yml │ │ └── plugin.yml └── build.gradle ├── core └── src │ └── main │ ├── java │ └── com │ │ └── nisovin │ │ └── magicspells │ │ ├── util │ │ ├── OverridePriority.java │ │ ├── ModifierResult.java │ │ ├── trackers │ │ │ └── Tracker.java │ │ ├── CastResult.java │ │ ├── config │ │ │ ├── VariableConfigData.java │ │ │ ├── expression │ │ │ │ └── functions │ │ │ │ │ ├── SignumFunction.java │ │ │ │ │ ├── CbrtFunction.java │ │ │ │ │ ├── ExpFunction.java │ │ │ │ │ ├── Log1pFunction.java │ │ │ │ │ ├── Expm1Function.java │ │ │ │ │ ├── Log2Function.java │ │ │ │ │ └── PowFunction.java │ │ │ └── ConfigData.java │ │ ├── ValidTargetChecker.java │ │ ├── bounds │ │ │ ├── Space.java │ │ │ └── SpaceCombined.java │ │ ├── projectile │ │ │ ├── ProjectileManagerEgg.java │ │ │ ├── ProjectileManagerArrow.java │ │ │ ├── ProjectileManagerTrident.java │ │ │ ├── ProjectileManagerFishHook.java │ │ │ ├── ProjectileManagerFireball.java │ │ │ ├── ProjectileManagerLlamaSpit.java │ │ │ ├── ProjectileManagerSnowball.java │ │ │ ├── ProjectileManagerEnderPearl.java │ │ │ ├── ProjectileManagerWitherSkull.java │ │ │ ├── ProjectileManagerDragonFireball.java │ │ │ ├── ProjectileManagerLargeFireball.java │ │ │ ├── ProjectileManagerShulkerBullet.java │ │ │ ├── ProjectileManagerSmallFireball.java │ │ │ ├── ProjectileManagerSpectralArrow.java │ │ │ ├── ProjectileManagerThrownExpBottle.java │ │ │ ├── ProjectileManagerSplashPotion.java │ │ │ ├── ProjectileManagerLingeringPotion.java │ │ │ └── ProjectileManagerThrownPotion.java │ │ ├── DeprecationNotice.java │ │ ├── messagelistener │ │ │ ├── MessageListener.java │ │ │ └── MessageListenerFactory.java │ │ ├── Name.java │ │ ├── itemreader │ │ │ └── alternative │ │ │ │ ├── ItemConfigTransformer.java │ │ │ │ └── SpigotReader.java │ │ ├── TargetInfo.java │ │ ├── RegexUtil.java │ │ ├── Angle.java │ │ ├── DependsOn.java │ │ ├── compat │ │ │ ├── DummyExemptionAssistant.java │ │ │ ├── ExemptionAssistant.java │ │ │ └── EventUtil.java │ │ ├── recipes │ │ │ ├── wrapper │ │ │ │ ├── CustomRecipe.java │ │ │ │ ├── PotionRecipe.java │ │ │ │ └── CraftingRecipe.java │ │ │ ├── types │ │ │ │ ├── PotionRecipeFactory.java │ │ │ │ ├── StonecuttingRecipeFactory.java │ │ │ │ └── CraftingRecipeFactory.java │ │ │ └── RecipeType.java │ │ ├── ai │ │ │ └── CustomGoals.java │ │ ├── ItemUtil.java │ │ ├── MagicConversationPrefix.java │ │ ├── BooleanUtils.java │ │ ├── TimeUtil.java │ │ └── magicitems │ │ │ └── MagicItem.java │ │ ├── mana │ │ └── ManaChangeReason.java │ │ ├── events │ │ ├── IMagicSpellsCompatEvent.java │ │ ├── MagicSpellsBlockBreakEvent.java │ │ ├── MagicSpellsEntityRegainHealthEvent.java │ │ ├── PortalEnterEvent.java │ │ ├── PortalLeaveEvent.java │ │ ├── MagicSpellsPlayerInteractEvent.java │ │ ├── SpellSelectionChangedEvent.java │ │ ├── SpellbookReloadEvent.java │ │ ├── MagicSpellsBlockPlaceEvent.java │ │ └── SpellSelectionChangeEvent.java │ │ ├── exception │ │ └── MagicException.java │ │ ├── castmodifiers │ │ ├── customdata │ │ │ └── CustomData.java │ │ ├── conditions │ │ │ ├── AlwaysCondition.java │ │ │ ├── OwnedLoopActiveCondition.java │ │ │ ├── LeashedCondition.java │ │ │ ├── ClimbingCondition.java │ │ │ ├── SilentCondition.java │ │ │ ├── SleepingCondition.java │ │ │ ├── SolidCondition.java │ │ │ ├── UnderWaterCondition.java │ │ │ ├── BurnableCondition.java │ │ │ ├── FixedPoseCondition.java │ │ │ ├── PassableCondition.java │ │ │ ├── BuildableCondition.java │ │ │ ├── CollidableCondition.java │ │ │ ├── LineOfSightCondition.java │ │ │ ├── ReplaceableCondition.java │ │ │ ├── DayCondition.java │ │ │ ├── FixedTimeCondition.java │ │ │ ├── GlidingCondition.java │ │ │ ├── OnGroundCondition.java │ │ │ ├── OnLeashCondition.java │ │ │ ├── SneakingCondition.java │ │ │ ├── SwimmingCondition.java │ │ │ ├── FallingCondition.java │ │ │ ├── RiptidingCondition.java │ │ │ ├── CanPickupItemsCondition.java │ │ │ ├── CustomNameVisibleCondition.java │ │ │ ├── RainingCondition.java │ │ │ ├── FlyingCondition.java │ │ │ ├── NightCondition.java │ │ │ ├── StormCondition.java │ │ │ ├── ThunderingCondition.java │ │ │ ├── IsNPCCondition.java │ │ │ ├── PermissionCondition.java │ │ │ ├── PlayerOnlineCondition.java │ │ │ ├── BlockingCondition.java │ │ │ └── util │ │ │ │ └── OperatorCondition.java │ │ └── Condition.java │ │ ├── variables │ │ ├── meta │ │ │ ├── CurrentTickVariable.java │ │ │ ├── PlayersOnlineVariable.java │ │ │ ├── TimestampSecondsVariable.java │ │ │ ├── TimestampMillisecondsVariable.java │ │ │ ├── TimestampMinutesVariable.java │ │ │ ├── TimestampDaysVariable.java │ │ │ ├── TimestampHoursVariable.java │ │ │ ├── EntityIDVariable.java │ │ │ ├── MaxFireTicksVariable.java │ │ │ ├── AttackCooldownVariable.java │ │ │ ├── MaxFreezeTicksVariable.java │ │ │ ├── SleepTicksVariable.java │ │ │ ├── ForwardsMovementVariable.java │ │ │ ├── SidewaysMovementVariable.java │ │ │ ├── BedCoordXVariable.java │ │ │ ├── BedCoordYVariable.java │ │ │ ├── BedCoordZVariable.java │ │ │ ├── BodyYawVariable.java │ │ │ ├── ExperienceVariable.java │ │ │ ├── FreezeTicksVariable.java │ │ │ ├── FireTicksVariable.java │ │ │ ├── FlySpeedVariable.java │ │ │ ├── LastDamageVariable.java │ │ │ ├── ExhaustionVariable.java │ │ │ ├── ExperienceLevelVariable.java │ │ │ ├── MaximumAirVariable.java │ │ │ ├── WalkSpeedVariable.java │ │ │ ├── SaturationVariable.java │ │ │ ├── FallDistanceVariable.java │ │ │ ├── NoDamageTicksVariable.java │ │ │ ├── RemainingAirVariable.java │ │ │ ├── StarvationRateVariable.java │ │ │ ├── AbsorptionVariable.java │ │ │ ├── SaturatedRegenRateVariable.java │ │ │ ├── MaximumNoDamageTicksVariable.java │ │ │ ├── UnsaturatedRegenRateVariable.java │ │ │ ├── MaxHealthVariable.java │ │ │ ├── CoordXVariable.java │ │ │ ├── CoordYVariable.java │ │ │ ├── CoordZVariable.java │ │ │ ├── FoodLevelVariable.java │ │ │ ├── HealthScaleVariable.java │ │ │ ├── CoordYawVariable.java │ │ │ ├── CoordPitchVariable.java │ │ │ ├── VelocityXVariable.java │ │ │ ├── VelocityYVariable.java │ │ │ ├── VelocityZVariable.java │ │ │ ├── CompassTargetXVariable.java │ │ │ ├── CompassTargetYVariable.java │ │ │ ├── CompassTargetZVariable.java │ │ │ ├── AttributeVariable.java │ │ │ ├── CurrentHealthVariable.java │ │ │ ├── RespawnCoordXVariable.java │ │ │ ├── RespawnCoordYVariable.java │ │ │ ├── RespawnCoordZVariable.java │ │ │ ├── MaxManaVariable.java │ │ │ ├── ManaRegenVariable.java │ │ │ ├── ManaVariable.java │ │ │ └── AltitudeVariable.java │ │ └── variabletypes │ │ │ ├── SquaredDistanceToLocationVariable.java │ │ │ ├── MetaVariable.java │ │ │ ├── GlobalVariable.java │ │ │ ├── PlayerVariable.java │ │ │ └── PlayerStringVariable.java │ │ ├── spells │ │ ├── DamageSpell.java │ │ ├── targeted │ │ │ └── cleanse │ │ │ │ ├── util │ │ │ │ ├── Cleanser.java │ │ │ │ └── Cleansers.java │ │ │ │ ├── FireCleanser.java │ │ │ │ ├── FreezeCleanser.java │ │ │ │ ├── DotSpellCleanser.java │ │ │ │ ├── BuffSpellCleanser.java │ │ │ │ ├── LoopSpellCleanser.java │ │ │ │ ├── StunSpellCleanser.java │ │ │ │ ├── OrbitSpellCleanser.java │ │ │ │ ├── TotemSpellCleanser.java │ │ │ │ ├── SilenceSpellCleanser.java │ │ │ │ └── LevitateSpellCleanser.java │ │ ├── InstantSpell.java │ │ ├── instant │ │ │ ├── DummySpell.java │ │ │ └── CraftSpell.java │ │ ├── passive │ │ │ ├── JoinListener.java │ │ │ ├── QuitListener.java │ │ │ ├── RespawnListener.java │ │ │ ├── StopSwimListener.java │ │ │ ├── StartSwimListener.java │ │ │ ├── DeathListener.java │ │ │ ├── EnterBedListener.java │ │ │ ├── LeaveBedListener.java │ │ │ ├── MagicSpellsLoadedListener.java │ │ │ ├── OffhandSwapListener.java │ │ │ ├── StartSprintListener.java │ │ │ ├── StopFlyListener.java │ │ │ ├── PlayerMoveToBlockListener.java │ │ │ ├── StartFlyListener.java │ │ │ ├── StopSneakListener.java │ │ │ ├── StopSprintListener.java │ │ │ ├── StartSneakListener.java │ │ │ ├── StopGlideListener.java │ │ │ ├── ShootListener.java │ │ │ └── StartGlideListener.java │ │ └── CommandSpell.java │ │ ├── commands │ │ └── HelpPermission.java │ │ ├── storage │ │ ├── StorageHandler.java │ │ └── types │ │ │ └── DatabaseStorage.java │ │ ├── spelleffects │ │ ├── effecttypes │ │ │ ├── EffectLibEntityEffect.java │ │ │ ├── ExplosionEffect.java │ │ │ ├── LightningEffect.java │ │ │ ├── DragonDeathEffect.java │ │ │ ├── EnderSignalEffect.java │ │ │ ├── MobSpawnerEffect.java │ │ │ ├── StopUsingItemEffect.java │ │ │ ├── CompleteUsingItemEffect.java │ │ │ └── SplashPotionEffect.java │ │ └── util │ │ │ └── EffectlibSpellEffect.java │ │ └── handlers │ │ ├── EnchantmentHandler.java │ │ └── PotionEffectHandler.java │ ├── resources │ ├── plugin.yml │ ├── zones.yml │ └── defaults.yml │ └── antlr │ ├── SpellFilter.g4 │ ├── RegistryEntryPredicate.g4 │ └── InputPredicate.g4 ├── gradle.properties ├── .github └── ISSUE_TEMPLATE │ └── config.yml ├── factions ├── src │ └── main │ │ ├── resources │ │ └── plugin.yml │ │ └── java │ │ └── com │ │ └── nisovin │ │ └── magicspells │ │ └── factions │ │ └── conditions │ │ └── HasFactionCondition.java └── build.gradle ├── shop ├── src │ └── main │ │ ├── resources │ │ ├── plugin.yml │ │ └── config.yml │ │ └── java │ │ └── com │ │ └── nisovin │ │ └── magicspells │ │ └── shop │ │ └── Perm.java └── build.gradle └── settings.gradle.kts /jitpack.yml: -------------------------------------------------------------------------------- 1 | jdk: 2 | - openjdk21 3 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheComputerGeek2/MagicSpells/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.class 2 | *.iml 3 | .classpath 4 | .project 5 | .settings/org.eclipse.jdt.core.prefs 6 | .idea/ 7 | Build/ 8 | .gradle/ 9 | -------------------------------------------------------------------------------- /teams/build.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | implementation project(":core") 3 | } 4 | 5 | jar { 6 | archiveFileName = "MagicSpellsTeams.jar" 7 | } 8 | -------------------------------------------------------------------------------- /memory/build.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | implementation project(":core") 3 | } 4 | 5 | jar { 6 | archiveFileName = "MagicSpellsMemory.jar" 7 | } 8 | -------------------------------------------------------------------------------- /nms/shared/build.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | implementation("me.libraryaddict.disguises:libsdisguises:10.0.44-SNAPSHOT") { transitive = false } 3 | } 4 | -------------------------------------------------------------------------------- /towny/src/main/resources/config.yml: -------------------------------------------------------------------------------- 1 | disallowed-in-towns: 2 | - forcepush 3 | - fireball 4 | - lightning 5 | - explode 6 | - explosivearrow 7 | - phase 8 | - volley -------------------------------------------------------------------------------- /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/ModifierResult.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.util; 2 | 3 | public record ModifierResult(SpellData data, boolean check) { 4 | } 5 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | version = 4.0-Beta-18 2 | groupId = com.nisovin.magicspells 3 | 4 | org.gradle.parallel=true 5 | org.gradle.configuration-cache=true 6 | org.gradle.configuration-cache.parallel=true 7 | -------------------------------------------------------------------------------- /nms/latest/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id "io.papermc.paperweight.userdev" 3 | } 4 | 5 | dependencies { 6 | paperweight.paperDevBundle("1.21.11-rc2-R0.1-SNAPSHOT") 7 | implementation project(":nms:shared") 8 | } 9 | -------------------------------------------------------------------------------- /nms/v1_21_10/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id "io.papermc.paperweight.userdev" 3 | } 4 | 5 | dependencies { 6 | paperweight.paperDevBundle("1.21.10-R0.1-SNAPSHOT") 7 | implementation project(":nms:shared") 8 | } 9 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /towny/build.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | implementation project(":core") 3 | implementation("com.palmergames.bukkit.towny:towny:0.100.1.0") { transitive = false } 4 | } 5 | 6 | jar { 7 | archiveFileName = "MagicSpellsTowny.jar" 8 | } 9 | -------------------------------------------------------------------------------- /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/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/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 | -------------------------------------------------------------------------------- /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 -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-9.1.0-bin.zip 4 | networkTimeout=10000 5 | validateDistributionUrl=true 6 | zipStoreBase=GRADLE_USER_HOME 7 | zipStorePath=wrapper/dists 8 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /shop/build.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | implementation project(":core") 3 | implementation("net.milkbowl.vault:VaultAPI: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 | -------------------------------------------------------------------------------- /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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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 | -------------------------------------------------------------------------------- /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_10") 13 | 14 | pluginManagement { 15 | repositories { 16 | gradlePluginPortal() 17 | maven("https://repo.papermc.io/repository/maven-public/") 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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 -------------------------------------------------------------------------------- /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/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/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/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/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/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.10" 7 | softdepend: 8 | - GriefPrevention 9 | - Vault 10 | - ProtocolLib 11 | - WorldGuard 12 | - LibsDisguises 13 | - NoCheatPlus 14 | - PlaceholderAPI 15 | - XGlow 16 | - packetevents 17 | -------------------------------------------------------------------------------- /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/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/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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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/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/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/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 | 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 | denied-spells: 18 | - blink 19 | - gate 20 | - mark 21 | - recall 22 | -------------------------------------------------------------------------------- /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/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/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/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/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/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/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/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/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/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/recipes/wrapper/CustomRecipe.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.util.recipes.wrapper; 2 | 3 | import org.bukkit.NamespacedKey; 4 | 5 | import org.jetbrains.annotations.NotNull; 6 | 7 | public abstract class CustomRecipe { 8 | 9 | @NotNull 10 | private final NamespacedKey key; 11 | 12 | public CustomRecipe(@NotNull NamespacedKey key) { 13 | this.key = key; 14 | } 15 | 16 | @NotNull 17 | public NamespacedKey getKey() { 18 | return key; 19 | } 20 | 21 | public abstract void add(); 22 | 23 | public abstract void remove(); 24 | 25 | } 26 | -------------------------------------------------------------------------------- /core/src/main/antlr/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/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/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/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/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/ItemUtil.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.util; 2 | 3 | import org.bukkit.inventory.ItemStack; 4 | import org.bukkit.inventory.meta.ItemMeta; 5 | import org.bukkit.inventory.meta.Damageable; 6 | 7 | public class ItemUtil { 8 | 9 | public static int getDurability(ItemStack item) { 10 | return item.getItemMeta() instanceof Damageable damageable ? damageable.getDamage() : 0; 11 | } 12 | 13 | public static int getCustomModelData(ItemMeta meta) { 14 | if (meta == null) return 0; 15 | if (meta.hasCustomModelData()) return meta.getCustomModelData(); 16 | return 0; 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /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/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/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 | @SuppressWarnings("removal") 9 | public class MagicConversationPrefix implements ConversationPrefix { 10 | 11 | private String prefix; 12 | 13 | public MagicConversationPrefix(String prefix) { 14 | this.prefix = prefix; 15 | } 16 | 17 | @Override 18 | @NotNull 19 | public String getPrefix(@NotNull ConversationContext paramConversationContext) { 20 | return prefix; 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /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/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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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/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/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/antlr/RegistryEntryPredicate.g4: -------------------------------------------------------------------------------- 1 | grammar RegistryEntryPredicate; 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 | | '#' tag=RESOURCE_LOCATION # tag 17 | | entry=RESOURCE_LOCATION # entry 18 | ; 19 | 20 | WHITESPACE: [\p{White_Space}]+ -> skip; 21 | 22 | RESOURCE_LOCATION: (NAMESPACE ':')? PATH; 23 | 24 | NAMESPACE: [-._0-9a-z]+; 25 | 26 | PATH: [-._/0-9a-z]+; 27 | 28 | -------------------------------------------------------------------------------- /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/util/recipes/wrapper/PotionRecipe.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.util.recipes.wrapper; 2 | 3 | import org.bukkit.Bukkit; 4 | 5 | import io.papermc.paper.potion.PotionMix; 6 | 7 | import org.jetbrains.annotations.NotNull; 8 | 9 | public class PotionRecipe extends CustomRecipe { 10 | 11 | @NotNull 12 | private final PotionMix mix; 13 | 14 | public PotionRecipe(@NotNull PotionMix mix) { 15 | super(mix.getKey()); 16 | this.mix = mix; 17 | } 18 | 19 | @Override 20 | public void add() { 21 | Bukkit.getPotionBrewer().addPotionMix(mix); 22 | } 23 | 24 | @Override 25 | public void remove() { 26 | Bukkit.getPotionBrewer().removePotionMix(getKey()); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /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/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/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/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/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/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/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/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/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/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/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/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/antlr/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/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/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 | -------------------------------------------------------------------------------- /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. -------------------------------------------------------------------------------- /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/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/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/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 | 7 | import com.nisovin.magicspells.variables.variabletypes.MetaVariable; 8 | 9 | public class CoordXVariable extends MetaVariable { 10 | 11 | @Override 12 | public double getValue(String player) { 13 | Player p = Bukkit.getPlayerExact(player); 14 | if (p != null) return p.getLocation().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.getLocation(); 24 | to.setX(amount); 25 | p.teleportAsync(to); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /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 | 7 | import com.nisovin.magicspells.variables.variabletypes.MetaVariable; 8 | 9 | public class CoordYVariable extends MetaVariable { 10 | 11 | @Override 12 | public double getValue(String player) { 13 | Player p = Bukkit.getPlayerExact(player); 14 | if (p != null) return p.getLocation().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.getLocation(); 24 | to.setY(amount); 25 | p.teleportAsync(to); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /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 | 7 | import com.nisovin.magicspells.variables.variabletypes.MetaVariable; 8 | 9 | public class CoordZVariable extends MetaVariable { 10 | 11 | @Override 12 | public double getValue(String player) { 13 | Player p = Bukkit.getPlayerExact(player); 14 | if (p != null) return p.getLocation().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.getLocation(); 24 | to.setZ(amount); 25 | p.teleportAsync(to); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /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/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/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/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/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 | 7 | import com.nisovin.magicspells.variables.variabletypes.MetaVariable; 8 | 9 | public class CoordYawVariable extends MetaVariable { 10 | 11 | @Override 12 | public double getValue(String player) { 13 | Player p = Bukkit.getPlayerExact(player); 14 | if (p != null) return p.getLocation().getYaw(); 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.getLocation(); 24 | to.setYaw((float) amount); 25 | p.teleportAsync(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 | 7 | import com.nisovin.magicspells.variables.variabletypes.MetaVariable; 8 | 9 | public class CoordPitchVariable extends MetaVariable { 10 | 11 | @Override 12 | public double getValue(String player) { 13 | Player p = Bukkit.getPlayerExact(player); 14 | if (p != null) return p.getLocation().getPitch(); 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.getLocation(); 24 | to.setPitch((float) amount); 25 | p.teleportAsync(to); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /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/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/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/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/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/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/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/StopUsingItemEffect.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.spelleffects.effecttypes; 2 | 3 | import org.bukkit.entity.Entity; 4 | import org.bukkit.entity.LivingEntity; 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("stopusingitem") 12 | public class StopUsingItemEffect extends SpellEffect { 13 | 14 | @Override 15 | protected void loadFromConfig(ConfigurationSection config) { 16 | 17 | } 18 | 19 | @Override 20 | protected Runnable playEffectEntity(Entity entity, SpellData data) { 21 | if (entity instanceof LivingEntity livingEntity) 22 | livingEntity.clearActiveItem(); 23 | 24 | return null; 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /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/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/util/config/expression/functions/SignumFunction.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.util.config.expression.functions; 2 | 3 | import com.ezylang.evalex.Expression; 4 | import com.ezylang.evalex.parser.Token; 5 | import com.ezylang.evalex.EvaluationException; 6 | import com.ezylang.evalex.data.EvaluationValue; 7 | import com.ezylang.evalex.functions.AbstractFunction; 8 | import com.ezylang.evalex.functions.FunctionParameter; 9 | 10 | import com.nisovin.magicspells.util.Name; 11 | 12 | @Name("signum") 13 | @FunctionParameter(name = "value") 14 | public class SignumFunction extends AbstractFunction { 15 | 16 | @Override 17 | public EvaluationValue evaluate(Expression expression, Token functionToken, EvaluationValue... args) throws EvaluationException { 18 | return expression.convertValue(args[0].getNumberValue().signum()); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /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/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/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/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/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/util/recipes/wrapper/CraftingRecipe.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.util.recipes.wrapper; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.NamespacedKey; 5 | import org.bukkit.inventory.Recipe; 6 | 7 | import org.jetbrains.annotations.NotNull; 8 | 9 | public class CraftingRecipe extends CustomRecipe { 10 | 11 | @NotNull 12 | private final Recipe recipe; 13 | private final boolean autoDiscover; 14 | 15 | public CraftingRecipe(@NotNull Recipe recipe, NamespacedKey key, boolean autoDiscover) { 16 | super(key); 17 | this.recipe = recipe; 18 | this.autoDiscover = autoDiscover; 19 | } 20 | 21 | public boolean isAutoDiscover() { 22 | return autoDiscover; 23 | } 24 | 25 | @Override 26 | public void add() { 27 | Bukkit.addRecipe(recipe); 28 | } 29 | 30 | @Override 31 | public void remove() { 32 | Bukkit.removeRecipe(getKey()); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /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/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/spells/instant/CraftSpell.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.spells.instant; 2 | 3 | import org.bukkit.entity.Player; 4 | import org.bukkit.inventory.MenuType; 5 | 6 | import com.nisovin.magicspells.util.SpellData; 7 | import com.nisovin.magicspells.util.CastResult; 8 | import com.nisovin.magicspells.util.MagicConfig; 9 | import com.nisovin.magicspells.spells.InstantSpell; 10 | 11 | public class CraftSpell extends InstantSpell { 12 | 13 | public CraftSpell(MagicConfig config, String spellName) { 14 | super(config, spellName); 15 | } 16 | 17 | @Override 18 | public CastResult cast(SpellData data) { 19 | if (!(data.caster() instanceof Player caster)) return new CastResult(PostCastAction.ALREADY_HANDLED, data); 20 | 21 | MenuType.CRAFTING.create(caster).open(); 22 | playSpellEffects(data); 23 | 24 | return new CastResult(PostCastAction.HANDLE_NORMALLY, data); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /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/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/spelleffects/effecttypes/CompleteUsingItemEffect.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.spelleffects.effecttypes; 2 | 3 | import org.bukkit.entity.Entity; 4 | import org.bukkit.entity.LivingEntity; 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("completeusingitem") 12 | public class CompleteUsingItemEffect extends SpellEffect { 13 | 14 | 15 | @Override 16 | protected void loadFromConfig(ConfigurationSection config) { 17 | 18 | } 19 | 20 | @SuppressWarnings("UnstableApiUsage") 21 | @Override 22 | protected Runnable playEffectEntity(Entity entity, SpellData data) { 23 | if (entity instanceof LivingEntity livingEntity) 24 | livingEntity.completeUsingActiveItem(); 25 | 26 | return null; 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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 | *
    14 | *
  • {@link Name} (required): Holds the configuration name of the condition.
  • 15 | *
  • {@link DependsOn} (optional): Requires listed plugins to be enabled before this condition is created.
  • 16 | *
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/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/util/config/expression/functions/CbrtFunction.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.util.config.expression.functions; 2 | 3 | import com.ezylang.evalex.Expression; 4 | import com.ezylang.evalex.parser.Token; 5 | import com.ezylang.evalex.EvaluationException; 6 | import com.ezylang.evalex.data.EvaluationValue; 7 | import com.ezylang.evalex.functions.AbstractFunction; 8 | import com.ezylang.evalex.functions.FunctionParameter; 9 | 10 | import com.nisovin.magicspells.util.Name; 11 | 12 | import org.apache.commons.math4.core.jdkmath.AccurateMath; 13 | 14 | @Name("cbrt") 15 | @FunctionParameter(name = "value") 16 | public class CbrtFunction extends AbstractFunction { 17 | 18 | @Override 19 | public EvaluationValue evaluate(Expression expression, Token functionToken, EvaluationValue... args) throws EvaluationException { 20 | double x = args[0].getNumberValue().doubleValue(); 21 | return expression.convertDoubleValue(AccurateMath.cbrt(x)); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/util/config/expression/functions/ExpFunction.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.util.config.expression.functions; 2 | 3 | import com.ezylang.evalex.Expression; 4 | import com.ezylang.evalex.parser.Token; 5 | import com.ezylang.evalex.EvaluationException; 6 | import com.ezylang.evalex.data.EvaluationValue; 7 | import com.ezylang.evalex.functions.AbstractFunction; 8 | import com.ezylang.evalex.functions.FunctionParameter; 9 | 10 | import com.nisovin.magicspells.util.Name; 11 | 12 | import org.apache.commons.math4.core.jdkmath.AccurateMath; 13 | 14 | @Name("exp") 15 | @FunctionParameter(name = "value") 16 | public class ExpFunction extends AbstractFunction { 17 | 18 | @Override 19 | public EvaluationValue evaluate(Expression expression, Token functionToken, EvaluationValue... args) throws EvaluationException { 20 | double x = args[0].getNumberValue().doubleValue(); 21 | return expression.convertDoubleValue(AccurateMath.exp(x)); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/util/config/expression/functions/Log1pFunction.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.util.config.expression.functions; 2 | 3 | import com.ezylang.evalex.Expression; 4 | import com.ezylang.evalex.parser.Token; 5 | import com.ezylang.evalex.EvaluationException; 6 | import com.ezylang.evalex.data.EvaluationValue; 7 | import com.ezylang.evalex.functions.AbstractFunction; 8 | import com.ezylang.evalex.functions.FunctionParameter; 9 | 10 | import com.nisovin.magicspells.util.Name; 11 | 12 | import org.apache.commons.math4.core.jdkmath.AccurateMath; 13 | 14 | @Name("log1p") 15 | @FunctionParameter(name = "value") 16 | public class Log1pFunction extends AbstractFunction { 17 | 18 | @Override 19 | public EvaluationValue evaluate(Expression expression, Token token, EvaluationValue... args) throws EvaluationException { 20 | double x = args[0].getNumberValue().doubleValue(); 21 | return expression.convertDoubleValue(AccurateMath.log1p(x)); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /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.CastItem; 9 | import com.nisovin.magicspells.util.MagicConfig; 10 | 11 | public abstract class CommandSpell extends Spell { 12 | 13 | public CommandSpell(MagicConfig config, String spellName) { 14 | super(config, spellName); 15 | } 16 | 17 | @Override 18 | public boolean canBind(CastItem item) { 19 | return false; 20 | } 21 | 22 | @Override 23 | public boolean canCastWithItem() { 24 | return false; 25 | } 26 | 27 | @Override 28 | public boolean canCastByCommand() { 29 | return true; 30 | } 31 | 32 | @Override 33 | public abstract boolean castFromConsole(CommandSender sender, String[] args); 34 | 35 | @Override 36 | public abstract List tabComplete(CommandSender sender, String[] args); 37 | 38 | } 39 | -------------------------------------------------------------------------------- /core/src/main/java/com/nisovin/magicspells/util/config/expression/functions/Expm1Function.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.util.config.expression.functions; 2 | 3 | import com.ezylang.evalex.Expression; 4 | import com.ezylang.evalex.parser.Token; 5 | import com.ezylang.evalex.EvaluationException; 6 | import com.ezylang.evalex.data.EvaluationValue; 7 | import com.ezylang.evalex.functions.AbstractFunction; 8 | import com.ezylang.evalex.functions.FunctionParameter; 9 | 10 | import com.nisovin.magicspells.util.Name; 11 | 12 | import org.apache.commons.math4.core.jdkmath.AccurateMath; 13 | 14 | @Name("expm1") 15 | @FunctionParameter(name = "value") 16 | public class Expm1Function extends AbstractFunction { 17 | 18 | @Override 19 | public EvaluationValue evaluate(Expression expression, Token functionToken, EvaluationValue... args) throws EvaluationException { 20 | double x = args[0].getNumberValue().doubleValue(); 21 | return expression.convertDoubleValue(AccurateMath.expm1(x)); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /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/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/recipes/types/PotionRecipeFactory.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.util.recipes.types; 2 | 3 | import org.jetbrains.annotations.Nullable; 4 | 5 | import io.papermc.paper.potion.PotionMix; 6 | 7 | import org.bukkit.NamespacedKey; 8 | import org.bukkit.inventory.ItemStack; 9 | import org.bukkit.inventory.RecipeChoice; 10 | import org.bukkit.configuration.ConfigurationSection; 11 | 12 | import com.nisovin.magicspells.util.recipes.wrapper.PotionRecipe; 13 | 14 | public class PotionRecipeFactory extends RecipeFactory { 15 | 16 | @Override 17 | @Nullable 18 | protected PotionRecipe createRecipe(ConfigurationSection config, NamespacedKey key, ItemStack result) { 19 | RecipeChoice input = resolveRecipeChoice(config, "input"); 20 | RecipeChoice ingredient = resolveRecipeChoice(config, "ingredient"); 21 | if (input == null || ingredient == null) return null; 22 | 23 | return new PotionRecipe(new PotionMix(key, result, input, ingredient)); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /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/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/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/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/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/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/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/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/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/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/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/util/recipes/types/StonecuttingRecipeFactory.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.util.recipes.types; 2 | 3 | import org.jetbrains.annotations.Nullable; 4 | 5 | import org.bukkit.NamespacedKey; 6 | import org.bukkit.inventory.Recipe; 7 | import org.bukkit.inventory.ItemStack; 8 | import org.bukkit.inventory.RecipeChoice; 9 | import org.bukkit.inventory.StonecuttingRecipe; 10 | import org.bukkit.configuration.ConfigurationSection; 11 | 12 | public class StonecuttingRecipeFactory extends CraftingRecipeFactory { 13 | 14 | @Override 15 | @Nullable 16 | protected Recipe createCrafting(ConfigurationSection config, NamespacedKey key, ItemStack result) { 17 | RecipeChoice ingredient = resolveRecipeChoice(config,"ingredient"); 18 | if (ingredient == null) return null; 19 | 20 | StonecuttingRecipe recipe = new StonecuttingRecipe(key, result, ingredient); 21 | 22 | String group = config.getString("group", ""); 23 | if (!group.isBlank()) recipe.setGroup(group); 24 | 25 | return recipe; 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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/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/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/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/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/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/util/config/expression/functions/Log2Function.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.util.config.expression.functions; 2 | 3 | import com.ezylang.evalex.Expression; 4 | import com.ezylang.evalex.parser.Token; 5 | import com.ezylang.evalex.EvaluationException; 6 | import com.ezylang.evalex.data.EvaluationValue; 7 | import com.ezylang.evalex.functions.AbstractFunction; 8 | import com.ezylang.evalex.functions.FunctionParameter; 9 | 10 | import com.nisovin.magicspells.util.Name; 11 | 12 | import org.apache.commons.math4.core.jdkmath.AccurateMath; 13 | 14 | @Name("log2") 15 | @FunctionParameter(name = "value") 16 | public class Log2Function extends AbstractFunction { 17 | 18 | private static final Double LOG2 = AccurateMath.log(2); 19 | 20 | @Override 21 | public EvaluationValue evaluate(Expression expression, Token token, EvaluationValue... args) throws EvaluationException { 22 | double x = args[0].getNumberValue().doubleValue(); 23 | return expression.convertDoubleValue(AccurateMath.log(x) / LOG2); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /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/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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/util/recipes/types/CraftingRecipeFactory.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.util.recipes.types; 2 | 3 | import org.jetbrains.annotations.Nullable; 4 | 5 | import org.bukkit.NamespacedKey; 6 | import org.bukkit.inventory.Recipe; 7 | import org.bukkit.inventory.ItemStack; 8 | import org.bukkit.configuration.ConfigurationSection; 9 | 10 | import com.nisovin.magicspells.util.recipes.wrapper.CraftingRecipe; 11 | 12 | public abstract class CraftingRecipeFactory extends RecipeFactory { 13 | 14 | @Override 15 | @Nullable 16 | protected final CraftingRecipe createRecipe(ConfigurationSection config, NamespacedKey key, ItemStack result) { 17 | boolean autoDiscover = config.getBoolean("auto-discover", true); 18 | 19 | Recipe recipe = createCrafting(config, key, result); 20 | if (recipe == null) return null; 21 | 22 | return new CraftingRecipe(recipe, key, autoDiscover); 23 | } 24 | 25 | @Nullable 26 | protected abstract Recipe createCrafting(ConfigurationSection config, NamespacedKey key, ItemStack result); 27 | 28 | } 29 | -------------------------------------------------------------------------------- /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/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/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/util/recipes/RecipeType.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.util.recipes; 2 | 3 | import org.bukkit.configuration.ConfigurationSection; 4 | 5 | import com.nisovin.magicspells.util.recipes.types.*; 6 | import com.nisovin.magicspells.util.recipes.wrapper.CustomRecipe; 7 | 8 | public enum RecipeType { 9 | 10 | FURNACE(new CookingRecipeFactory.Furnace()), 11 | SMOKING(new CookingRecipeFactory.Smoking()), 12 | CAMPFIRE(new CookingRecipeFactory.Campfire()), 13 | BLASTING(new CookingRecipeFactory.Blasting()), 14 | STONECUTTING(new StonecuttingRecipeFactory()), 15 | SMITHING(new SmithingRecipeFactory()), 16 | SHAPELESS(new ShapelessRecipeFactory()), 17 | SHAPED(new ShapedRecipeFactory()), 18 | POTION(new PotionRecipeFactory()), 19 | 20 | ; 21 | 22 | private final RecipeFactory factory; 23 | 24 | RecipeType(RecipeFactory factory) { 25 | this.factory = factory; 26 | } 27 | 28 | public CustomRecipe create(ConfigurationSection config) { 29 | return factory.create(config); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /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/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/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/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/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/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/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/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/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/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/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/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/castmodifiers/conditions/IsNPCCondition.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.castmodifiers.conditions; 2 | 3 | import org.bukkit.Location; 4 | import org.bukkit.entity.EntityType; 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("isnpc") 13 | public class IsNPCCondition 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 isNPC(caster); 23 | } 24 | 25 | @Override 26 | public boolean check(LivingEntity caster, LivingEntity target) { 27 | return isNPC(target); 28 | } 29 | 30 | @Override 31 | public boolean check(LivingEntity caster, Location location) { 32 | return false; 33 | } 34 | 35 | private boolean isNPC(LivingEntity target) { 36 | return target.hasMetadata("NPC") || target.getType() == EntityType.MANNEQUIN; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /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/util/config/expression/functions/PowFunction.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.util.config.expression.functions; 2 | 3 | import com.ezylang.evalex.Expression; 4 | import com.ezylang.evalex.parser.Token; 5 | import com.ezylang.evalex.EvaluationException; 6 | import com.ezylang.evalex.data.EvaluationValue; 7 | import com.ezylang.evalex.functions.AbstractFunction; 8 | import com.ezylang.evalex.functions.FunctionParameter; 9 | 10 | import com.nisovin.magicspells.util.Name; 11 | 12 | import org.apache.commons.math4.core.jdkmath.AccurateMath; 13 | 14 | @Name("pow") 15 | @FunctionParameter(name = "base") 16 | @FunctionParameter(name = "exponent") 17 | public class PowFunction extends AbstractFunction { 18 | 19 | @Override 20 | public EvaluationValue evaluate(Expression expression, Token functionToken, EvaluationValue... args) throws EvaluationException { 21 | double base = args[0].getNumberValue().doubleValue(); 22 | double exponent = args[1].getNumberValue().doubleValue(); 23 | return expression.convertDoubleValue(AccurateMath.pow(base, exponent)); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /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/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/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/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/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/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/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/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/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/variables/meta/AltitudeVariable.java: -------------------------------------------------------------------------------- 1 | package com.nisovin.magicspells.variables.meta; 2 | 3 | import org.bukkit.*; 4 | import org.bukkit.entity.Player; 5 | 6 | import com.nisovin.magicspells.variables.variabletypes.MetaVariable; 7 | 8 | public class AltitudeVariable extends MetaVariable { 9 | 10 | @Override 11 | public double getValue(String player) { 12 | Player p = Bukkit.getPlayerExact(player); 13 | if (p == null) return 0; 14 | 15 | World world = p.getWorld(); 16 | int x = Location.locToBlock(p.getX()); 17 | int y = Location.locToBlock(p.getY()) - 1; 18 | int z = Location.locToBlock(p.getZ()); 19 | 20 | int highestPoint = world.getHighestBlockYAt(x, z, HeightMap.MOTION_BLOCKING); 21 | if (highestPoint <= y) return y - highestPoint; 22 | 23 | for (int i = y, min = world.getMinHeight(); i >= min; i--) { 24 | // Matches the check for HeightMap.MOTION_BLOCKING 25 | if (!world.getBlockAt(x, i, z).isSolid() && world.getFluidData(x, i, z).getFluidType() == Fluid.EMPTY) 26 | continue; 27 | 28 | return y - i; 29 | } 30 | 31 | return 0; 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 | --------------------------------------------------------------------------------