Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
plugins {
id("dev.magicspells.msjava")
id("io.papermc.paperweight.userdev") version "2.0.0-beta.21" apply false
id("io.papermc.paperweight.userdev") version "2.0.0-beta.24" apply false
}

subprojects {
apply plugin: "dev.magicspells.msjava"

dependencies {
compileOnly("io.papermc.paper:paper-api:26.1.2.build.+")
compileOnly("io.papermc.paper:paper-api:26.3.build.+")
}

processResources {
Expand Down
14 changes: 6 additions & 8 deletions core/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id("com.gradleup.shadow") version "9.4.1"
id("com.gradleup.shadow") version "9.6.1"
id("antlr")
}

Expand All @@ -11,26 +11,24 @@ dependencies {
implementation("org.incendo:cloud-minecraft-extras:2.0.1")
implementation("org.incendo:cloud-processors-requirements:1.0.0-rc.1")
implementation("org.bstats:bstats-bukkit:3.2.1")
implementation("com.github.ezylang:EvalEx:3.6.2")
implementation("com.ezylang:EvalEx:3.8.0")

implementation("org.antlr:antlr4-runtime:4.13.2")
antlr("org.antlr:antlr4:4.13.2")

implementation(project(path: ":nms:shared"))
implementation(project(path: ":nms:latest"))
implementation(project(path: ":nms:v26_1_2"))
implementation(project(path: ":nms:v26_2"))

compileOnly("com.github.retrooper:packetevents-spigot:2.11.2")
compileOnly("com.github.retrooper:packetevents-spigot:2.14.0")
compileOnly("net.dmulloy2:ProtocolLib:5.4.0")
compileOnly("me.libraryaddict.disguises:libsdisguises:11.0.16-SNAPSHOT")
compileOnly("me.libraryaddict.disguises:libsdisguises:26.11.10-SNAPSHOT")
compileOnly("net.milkbowl.vault:VaultAPI:1.7")
compileOnly("me.clip:placeholderapi:2.12.2")
compileOnly("com.github.GriefPrevention:GriefPrevention:18.0.0")
compileOnly("com.sk89q.worldguard:worldguard-core:7.1.0-SNAPSHOT")
compileOnly("com.sk89q.worldguard:worldguard-bukkit:7.1.0-SNAPSHOT")
compileOnly("com.sk89q.worldedit:worldedit-core:7.4.0-SNAPSHOT")
compileOnly("com.sk89q.worldedit:worldedit-bukkit:7.4.0-SNAPSHOT")
compileOnly("com.sk89q.worldedit:worldedit-core:7.4.6-SNAPSHOT")
compileOnly("com.sk89q.worldedit:worldedit-bukkit:7.4.6-SNAPSHOT")
}

/*
Expand Down
16 changes: 7 additions & 9 deletions core/src/main/java/com/nisovin/magicspells/MagicSpells.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import java.lang.reflect.Constructor;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.annotation.Annotation;

import java.net.URL;
import java.net.URLClassLoader;
Expand Down Expand Up @@ -93,6 +92,7 @@
import com.nisovin.magicspells.events.SpellLearnEvent.LearnSource;
import com.nisovin.magicspells.spelleffects.trackers.EffectTracker;
import com.nisovin.magicspells.spells.passive.util.PassiveListener;
import com.nisovin.magicspells.util.recipes.RecipeDiscoverListener;
import com.nisovin.magicspells.variables.variabletypes.GlobalVariable;
import com.nisovin.magicspells.spelleffects.trackers.AsyncEffectTracker;
import com.nisovin.magicspells.spelleffects.effecttypes.EffectLibEffect;
Expand Down Expand Up @@ -447,6 +447,8 @@ public void load() {
}
log("..." + MagicItems.getMagicItems().size() + " magic items loaded");

// Load custom recipes
registerEvents(new RecipeDiscoverListener());
if (config.isSection(path + "recipes")) {
log("Loading recipes...");
CustomRecipes.load(config.getSection(path + "recipes"));
Expand Down Expand Up @@ -2093,9 +2095,7 @@ public static void profilingReport() {
if (plugin.profilingTotalTime == null) return;
if (plugin.profilingRuns == null) return;

PrintWriter writer = null;
try {
writer = new PrintWriter(new File(plugin.getDataFolder(), "profiling_report_" + System.currentTimeMillis() + ".txt"));
try (PrintWriter writer = new PrintWriter(new File(plugin.getDataFolder(), "profiling_report_" + System.currentTimeMillis() + ".txt"))) {
long totalTime = 0;
writer.println("Key\tRuns\tAvg\tTotal");
for (String key : plugin.profilingTotalTime.keySet()) {
Expand All @@ -2109,8 +2109,6 @@ public static void profilingReport() {
} catch (Exception ex) {
error("Failed to save profiling report");
handleException(ex);
} finally {
if (writer != null) writer.close();
}
plugin.profilingTotalTime.clear();
plugin.profilingRuns.clear();
Expand Down Expand Up @@ -2249,11 +2247,11 @@ public void unload() {
cooldown = cooldowns.get(id);
if (cooldown <= System.currentTimeMillis()) continue;
writer.append(spell.getInternalName())
.append(String.valueOf(':'))
.append(':')
.append(id.toString())
.append(String.valueOf(':'))
.append(':')
.append(String.valueOf(cooldown))
.append(String.valueOf('\n'));
.append('\n');
}
}
writer.close();
Expand Down
3 changes: 1 addition & 2 deletions core/src/main/java/com/nisovin/magicspells/Spellbook.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import java.util.*;

import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.bukkit.inventory.ItemStack;
Expand Down Expand Up @@ -273,7 +272,7 @@ public boolean hasSpell(Spell spell, boolean checkGranted) {
protected CastItem getCastItemForCycling(ItemStack item) {
CastItem castItem;
if (item != null) castItem = new CastItem(item);
else castItem = new CastItem(new ItemStack(Material.AIR));
else castItem = new CastItem(ItemStack.empty());

List<Spell> spells = itemSpells.get(castItem);
if (spells != null && (spells.size() > 1 || (spells.size() == 1 && MagicSpells.canCycleToNoSpell()))) return castItem;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ private boolean checkInventory(Inventory inventory) {
if (item == null) continue;
Component itemName = null;
try {
if (item.hasItemMeta() && item.getItemMeta().hasDisplayName()) itemName = item.getItemMeta().displayName();
if (item.hasItemMeta() && item.getItemMeta().hasCustomName()) itemName = item.getItemMeta().customName();
} catch (Exception e) {
DebugHandler.debugGeneral(e);
}
Expand All @@ -112,7 +112,7 @@ private boolean checkEquipment(EntityEquipment entityEquipment) {
if (item == null) continue;
Component itemName = null;
try {
if (item.hasItemMeta() && item.getItemMeta().hasDisplayName()) itemName = item.getItemMeta().displayName();
if (item.hasItemMeta() && item.getItemMeta().hasCustomName()) itemName = item.getItemMeta().customName();
} catch (Exception e) {
DebugHandler.debugGeneral(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ private boolean checkHolding(LivingEntity target) {
Component name = null;

try {
if (item.hasItemMeta() && item.getItemMeta().hasDisplayName()) name = item.getItemMeta().displayName();
if (item.hasItemMeta() && item.getItemMeta().hasCustomName()) name = item.getItemMeta().customName();
} catch (Exception e) {
DebugHandler.debugGeneral(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ private boolean offHand(LivingEntity target) {
int durability = meta instanceof Damageable ? ((Damageable) meta).getDamage() : 0;
Component name = null;
try {
if (item.hasItemMeta() && item.getItemMeta().hasDisplayName()) name = item.getItemMeta().displayName();
if (item.hasItemMeta() && item.getItemMeta().hasCustomName()) name = item.getItemMeta().customName();
} catch (Exception e) {
// no op
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ private boolean checkItem(ItemStack item) {
int durability = meta instanceof Damageable ? ((Damageable) meta).getDamage() : 0;
Component name = null;
try {
if (item.hasItemMeta() && item.getItemMeta().hasDisplayName()) name = item.getItemMeta().displayName();
if (item.hasItemMeta() && item.getItemMeta().hasCustomName()) name = item.getItemMeta().customName();
} catch (Exception e) {
DebugHandler.debugGeneral(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import org.jetbrains.annotations.NotNull;

import java.util.*;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;
import java.util.concurrent.CompletableFuture;

Expand Down Expand Up @@ -115,7 +114,7 @@ public static ParserDescriptor<CommandSourceStack, String[]> spellCastArgumentsP
}

@Override
public @NotNull CompletableFuture<@NotNull ? extends Iterable<@NotNull ? extends Suggestion>> suggestionsFuture(@NotNull CommandContext<CommandSourceStack> context, @NotNull CommandInput input) {
public @NotNull CompletableFuture<? extends @NotNull Iterable<? extends @NotNull Suggestion>> suggestionsFuture(@NotNull CommandContext<CommandSourceStack> context, @NotNull CommandInput input) {
if (context.contains(PARSE_SUGGESTIONS))
return CompletableFuture.completedFuture(context.get(PARSE_SUGGESTIONS));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,19 @@ public class PotionEffectHandler {

static {
// Add bukkit and minecraft potion effect names
for (PotionEffectType potionEffect : Registry.EFFECT) {
//noinspection deprecation
potionEffects.put(potionEffect.getName().toLowerCase(), potionEffect);

// Add legacy values
potionEffects.put("slow", PotionEffectType.SLOWNESS);
potionEffects.put("fast_digging", PotionEffectType.HASTE);
potionEffects.put("slow_digging", PotionEffectType.MINING_FATIGUE);
potionEffects.put("increase_damage", PotionEffectType.STRENGTH);
potionEffects.put("heal", PotionEffectType.INSTANT_HEALTH);
potionEffects.put("harm", PotionEffectType.INSTANT_DAMAGE);
potionEffects.put("jump", PotionEffectType.JUMP_BOOST);
potionEffects.put("confusion", PotionEffectType.NAUSEA);
potionEffects.put("damage_resistance", PotionEffectType.RESISTANCE);

for (PotionEffectType potionEffect : Registry.MOB_EFFECT) {
potionEffects.put(potionEffect.key().value(), potionEffect);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerItemHeldEvent;
import org.bukkit.event.player.PlayerAnimationEvent;

import io.papermc.paper.event.player.PlayerArmSwingEvent;
import io.papermc.paper.event.player.PrePlayerAttackEntityEvent;

import com.nisovin.magicspells.Spell;
Expand Down Expand Up @@ -96,7 +96,7 @@ public void onPlayerInteract(PlayerInteractEvent event) {
}

@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerAnimation(PlayerAnimationEvent event) {
public void onPlayerArmSwing(PlayerArmSwingEvent event) {
if (!MagicSpells.isCastingOnAnimate()) return;

Player player = event.getPlayer();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ public class DanceCastListener implements Listener {
private Map<String, Integer> playerTasks = new HashMap<>();
private Map<String, Location> playerLocations = new HashMap<>();

private boolean dynamicCasting = false;
private boolean dynamicCasting;
private boolean enableMovement = false;
private boolean enableDoubleJump = false;

private String startSound = null;
private String startSound;
private float startSoundVolume = 1;
private float startSoundPitch = 1;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ private void updateBar(Player player, SpellData data) {
else progress = this.progress.get(data);
} else progress = this.progress.get(data);

progress = Math.min(Math.max(progress, 0), 1);
progress = Math.clamp(progress, 0, 1);

String title = Util.getLegacyFromComponent(Util.getMiniMessage(this.title, player, data));
bar.set(title, progress, barStyle.get(data), barColor.get(data), visible.get(data));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ public Runnable playEffectLocation(Location location, SpellData data) {
private void smoke(World w, Block b, int r) {
Location loc = b.getLocation();
if (r <= 5) {
for (int i = 0; i <= 8; i += 2) w.playEffect(loc, Effect.SMOKE, i);
for (int i = 0; i <= 8; i += 2) w.playEffect(loc, Effect.SMOKE_SHOOT, i);
} else if (r <= 8) {
w.playEffect(loc, Effect.SMOKE, random.nextInt(9));
w.playEffect(loc, Effect.SMOKE, random.nextInt(9));
w.playEffect(loc, Effect.SMOKE_SHOOT, random.nextInt(9));
w.playEffect(loc, Effect.SMOKE_SHOOT, random.nextInt(9));
} else {
w.playEffect(loc, Effect.SMOKE, random.nextInt(9));
w.playEffect(loc, Effect.SMOKE_SHOOT, random.nextInt(9));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ protected void loadFromConfig(ConfigurationSection config) {

}

@SuppressWarnings("UnstableApiUsage")
@Override
protected Runnable playEffectEntity(Entity entity, SpellData data) {
if (entity instanceof LivingEntity livingEntity)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
package com.nisovin.magicspells.spelleffects.effecttypes;

import java.util.List;

import org.bukkit.*;
import org.bukkit.entity.Firework;
import org.bukkit.inventory.meta.FireworkMeta;
import org.bukkit.inventory.ItemStack;
import org.bukkit.persistence.PersistentDataType;
import org.bukkit.configuration.ConfigurationSection;

import io.papermc.paper.datacomponent.item.Fireworks;
import io.papermc.paper.datacomponent.DataComponentTypes;

import com.nisovin.magicspells.util.Name;
import com.nisovin.magicspells.MagicSpells;
import com.nisovin.magicspells.util.SpellData;
Expand Down Expand Up @@ -87,10 +92,9 @@ public Runnable playEffectLocation(Location location, SpellData data) {
.build();

location.getWorld().spawn(location, Firework.class, firework -> {
FireworkMeta meta = firework.getFireworkMeta();
meta.addEffect(effect);
meta.setPower(0);
firework.setFireworkMeta(meta);
ItemStack rocket = firework.getItem();
rocket.setData(DataComponentTypes.FIREWORKS, Fireworks.fireworks(List.of(effect), 0));
firework.setItem(rocket);

firework.setSilent(true);
firework.setTicksToDetonate(flightDuration.get(data));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public void loadFromConfig(ConfigurationSection config) {
public Runnable playEffectLocation(Location location, SpellData data) {
Material material = this.material.get(data);
if (material == null) return null;
ItemStack itemStack = new ItemStack(material);
ItemStack itemStack = ItemStack.of(material);

Location loc = location.clone().add(0, 1, 0);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public Runnable playEffectLocation(Location location, SpellData data) {
if (blockData == null) return null;

double range = this.range.get(data);
range = Math.max(Math.min(range, MagicSpells.getGlobalRadius()), 1);
range = Math.clamp(range, 1, MagicSpells.getGlobalRadius());

Collection<Player> nearbyPlayers = location.getWorld().getNearbyPlayers(location, range, range, range);

Expand Down
Loading
Loading