diff --git a/main/src/main/java/net/citizensnpcs/trait/versioned/SpellcasterTrait.java b/main/src/main/java/net/citizensnpcs/trait/versioned/SpellcasterTrait.java
new file mode 100644
index 000000000..1a33d6960
--- /dev/null
+++ b/main/src/main/java/net/citizensnpcs/trait/versioned/SpellcasterTrait.java
@@ -0,0 +1,68 @@
+package net.citizensnpcs.trait.versioned;
+
+import org.bukkit.command.CommandSender;
+import org.bukkit.entity.EntityType;
+import org.bukkit.entity.Spellcaster;
+import org.bukkit.entity.Spellcaster.Spell;
+
+import net.citizensnpcs.api.command.Command;
+import net.citizensnpcs.api.command.CommandContext;
+import net.citizensnpcs.api.command.Flag;
+import net.citizensnpcs.api.command.Requirements;
+import net.citizensnpcs.api.command.exception.CommandException;
+import net.citizensnpcs.api.command.exception.CommandUsageException;
+import net.citizensnpcs.api.npc.NPC;
+import net.citizensnpcs.api.persistence.Persist;
+import net.citizensnpcs.api.trait.Trait;
+import net.citizensnpcs.api.trait.TraitName;
+import net.citizensnpcs.api.util.Messaging;
+import net.citizensnpcs.util.Messages;
+
+@TraitName("spellcastertrait")
+public class SpellcasterTrait extends Trait {
+ @Persist
+ private Spell spell;
+
+ public SpellcasterTrait() {
+ super("spellcastertrait");
+ }
+
+ @Override
+ public void run() {
+ if (!npc.isSpawned() || !(npc.getEntity() instanceof Spellcaster))
+ return;
+ if (spell != null) {
+ ((Spellcaster) npc.getEntity()).setSpell(spell);
+ }
+
+ }
+
+ public void setSpell(Spell spell) {
+ this.spell = spell;
+ }
+
+ @Command(
+ aliases = { "npc" },
+ usage = "spellcaster (--spell spell)",
+ desc = "Sets spellcaster modifiers",
+ modifiers = { "spellcaster" },
+ min = 1,
+ max = 1,
+ flags = "d",
+ permission = "citizens.npc.spellcaster")
+ @Requirements(selected = true, ownership = true, types = { EntityType.EVOKER, EntityType.ILLUSIONER })
+ public static void Spellcaster(CommandContext args, CommandSender sender, NPC npc, @Flag("spell") Spell spell)
+ throws CommandException {
+ SpellcasterTrait trait = npc.getOrAddTrait(SpellcasterTrait.class);
+ String output = "";
+ if (spell != null) {
+ trait.setSpell(spell);
+ output += Messaging.tr(Messages.SPELL_SET, spell);
+ }
+ if (!output.isEmpty()) {
+ Messaging.send(sender, output.trim());
+ } else {
+ throw new CommandUsageException();
+ }
+ }
+}
diff --git a/main/src/main/java/net/citizensnpcs/util/Messages.java b/main/src/main/java/net/citizensnpcs/util/Messages.java
index b89727c18..cfa534bdb 100644
--- a/main/src/main/java/net/citizensnpcs/util/Messages.java
+++ b/main/src/main/java/net/citizensnpcs/util/Messages.java
@@ -337,6 +337,7 @@ public class Messages {
public static final String SPEED_MODIFIER_ABOVE_LIMIT = "citizens.commands.npc.speed.modifier-above-limit";
public static final String SPEED_MODIFIER_SET = "citizens.commands.npc.speed.set";
public static final String SPEED_TRIGGER_PROMPT = "citizens.editors.waypoints.triggers.speed.prompt";
+ public static final String SPELL_SET = "citizens.commands.npc.spellcaster.spell-set";
public static final String SWIMMING_SET = "citizens.commands.npc.swim.set";
public static final String SWIMMING_UNSET = "citizens.commands.npc.swim.unset";
public static final String TARGETABLE_SET = "citizens.commands.npc.targetable.set";
diff --git a/main/src/main/resources/messages_en.properties b/main/src/main/resources/messages_en.properties
index a2602fc61..db2878d32 100644
--- a/main/src/main/resources/messages_en.properties
+++ b/main/src/main/resources/messages_en.properties
@@ -244,6 +244,7 @@ citizens.commands.npc.skin.cleared=[[{0}]]''s skin name was cleared.
citizens.commands.npc.skin.layers-set=[[{0}]]''s skin layers: cape - [[{1}]], hat - [[{2}]], jacket - [[{3}]], sleeves - [[{4}]], pants - [[{5}]].
citizens.commands.npc.size.description=[[{0}]]''s size is [[{1}]].
citizens.commands.npc.size.set=[[{0}]]''s size set to [[{1}]].
+citizens.commands.npc.spellcaster.spell-set=Spell set to [[{0}]].
citizens.commands.npc.sound.invalid-sound=Invalid sound.
citizens.commands.npc.sound.set=[[{0}]]''s sounds are now: ambient - [[{1}]] hurt - [[{2}]] and death - [[{3}]].
citizens.commands.npc.sound.info=[[{0}]]''s sounds are: ambient - [[{1}]] hurt - [[{2}]] and death - [[{3}]].
Valid sounds are {4}.
diff --git a/v1_11_R1/src/main/java/net/citizensnpcs/nms/v1_11_R1/util/NMSImpl.java b/v1_11_R1/src/main/java/net/citizensnpcs/nms/v1_11_R1/util/NMSImpl.java
index 30f30d07f..181fd657a 100644
--- a/v1_11_R1/src/main/java/net/citizensnpcs/nms/v1_11_R1/util/NMSImpl.java
+++ b/v1_11_R1/src/main/java/net/citizensnpcs/nms/v1_11_R1/util/NMSImpl.java
@@ -186,6 +186,7 @@ import net.citizensnpcs.trait.versioned.LlamaTrait;
import net.citizensnpcs.trait.versioned.PolarBearTrait;
import net.citizensnpcs.trait.versioned.ShulkerTrait;
import net.citizensnpcs.trait.versioned.SnowmanTrait;
+import net.citizensnpcs.trait.versioned.SpellcasterTrait;
import net.citizensnpcs.util.EmptyChannel;
import net.citizensnpcs.util.Messages;
import net.citizensnpcs.util.NMS;
@@ -697,6 +698,7 @@ public class NMSImpl implements NMSBridge {
registerTraitWithCommand(manager, PolarBearTrait.class);
registerTraitWithCommand(manager, ShulkerTrait.class);
registerTraitWithCommand(manager, SnowmanTrait.class);
+ registerTraitWithCommand(manager, SpellcasterTrait.class);
}
private void loadEntityTypes() {
diff --git a/v1_12_R1/src/main/java/net/citizensnpcs/nms/v1_12_R1/util/NMSImpl.java b/v1_12_R1/src/main/java/net/citizensnpcs/nms/v1_12_R1/util/NMSImpl.java
index 5fe4c9ed6..9c4fcb8e7 100644
--- a/v1_12_R1/src/main/java/net/citizensnpcs/nms/v1_12_R1/util/NMSImpl.java
+++ b/v1_12_R1/src/main/java/net/citizensnpcs/nms/v1_12_R1/util/NMSImpl.java
@@ -189,6 +189,7 @@ import net.citizensnpcs.trait.versioned.ParrotTrait;
import net.citizensnpcs.trait.versioned.PolarBearTrait;
import net.citizensnpcs.trait.versioned.ShulkerTrait;
import net.citizensnpcs.trait.versioned.SnowmanTrait;
+import net.citizensnpcs.trait.versioned.SpellcasterTrait;
import net.citizensnpcs.util.EmptyChannel;
import net.citizensnpcs.util.Messages;
import net.citizensnpcs.util.NMS;
@@ -702,6 +703,7 @@ public class NMSImpl implements NMSBridge {
registerTraitWithCommand(manager, PolarBearTrait.class);
registerTraitWithCommand(manager, ShulkerTrait.class);
registerTraitWithCommand(manager, SnowmanTrait.class);
+ registerTraitWithCommand(manager, SpellcasterTrait.class);
}
private void loadEntityTypes() {
diff --git a/v1_13_R2/src/main/java/net/citizensnpcs/nms/v1_13_R2/util/NMSImpl.java b/v1_13_R2/src/main/java/net/citizensnpcs/nms/v1_13_R2/util/NMSImpl.java
index 8065d8aa6..000b9074a 100644
--- a/v1_13_R2/src/main/java/net/citizensnpcs/nms/v1_13_R2/util/NMSImpl.java
+++ b/v1_13_R2/src/main/java/net/citizensnpcs/nms/v1_13_R2/util/NMSImpl.java
@@ -202,6 +202,7 @@ import net.citizensnpcs.trait.versioned.PolarBearTrait;
import net.citizensnpcs.trait.versioned.PufferFishTrait;
import net.citizensnpcs.trait.versioned.ShulkerTrait;
import net.citizensnpcs.trait.versioned.SnowmanTrait;
+import net.citizensnpcs.trait.versioned.SpellcasterTrait;
import net.citizensnpcs.trait.versioned.TropicalFishTrait;
import net.citizensnpcs.util.EmptyChannel;
import net.citizensnpcs.util.Messages;
@@ -726,6 +727,7 @@ public class NMSImpl implements NMSBridge {
registerTraitWithCommand(manager, PolarBearTrait.class);
registerTraitWithCommand(manager, PufferFishTrait.class);
registerTraitWithCommand(manager, ShulkerTrait.class);
+ registerTraitWithCommand(manager, SpellcasterTrait.class);
registerTraitWithCommand(manager, SnowmanTrait.class);
registerTraitWithCommand(manager, TropicalFishTrait.class);
}
diff --git a/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/util/NMSImpl.java b/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/util/NMSImpl.java
index b5167d352..d21cf38ac 100644
--- a/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/util/NMSImpl.java
+++ b/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/util/NMSImpl.java
@@ -212,6 +212,7 @@ import net.citizensnpcs.trait.versioned.PolarBearTrait;
import net.citizensnpcs.trait.versioned.PufferFishTrait;
import net.citizensnpcs.trait.versioned.ShulkerTrait;
import net.citizensnpcs.trait.versioned.SnowmanTrait;
+import net.citizensnpcs.trait.versioned.SpellcasterTrait;
import net.citizensnpcs.trait.versioned.TropicalFishTrait;
import net.citizensnpcs.trait.versioned.VillagerTrait;
import net.citizensnpcs.util.EmptyChannel;
@@ -782,6 +783,7 @@ public class NMSImpl implements NMSBridge {
registerTraitWithCommand(manager, PhantomTrait.class);
registerTraitWithCommand(manager, PolarBearTrait.class);
registerTraitWithCommand(manager, PufferFishTrait.class);
+ registerTraitWithCommand(manager, SpellcasterTrait.class);
registerTraitWithCommand(manager, ShulkerTrait.class);
registerTraitWithCommand(manager, SnowmanTrait.class);
registerTraitWithCommand(manager, TropicalFishTrait.class);
diff --git a/v1_15_R1/src/main/java/net/citizensnpcs/nms/v1_15_R1/util/NMSImpl.java b/v1_15_R1/src/main/java/net/citizensnpcs/nms/v1_15_R1/util/NMSImpl.java
index 4d124e6be..95fefbea8 100644
--- a/v1_15_R1/src/main/java/net/citizensnpcs/nms/v1_15_R1/util/NMSImpl.java
+++ b/v1_15_R1/src/main/java/net/citizensnpcs/nms/v1_15_R1/util/NMSImpl.java
@@ -214,6 +214,7 @@ import net.citizensnpcs.trait.versioned.PolarBearTrait;
import net.citizensnpcs.trait.versioned.PufferFishTrait;
import net.citizensnpcs.trait.versioned.ShulkerTrait;
import net.citizensnpcs.trait.versioned.SnowmanTrait;
+import net.citizensnpcs.trait.versioned.SpellcasterTrait;
import net.citizensnpcs.trait.versioned.TropicalFishTrait;
import net.citizensnpcs.trait.versioned.VillagerTrait;
import net.citizensnpcs.util.EmptyChannel;
@@ -793,6 +794,7 @@ public class NMSImpl implements NMSBridge {
registerTraitWithCommand(manager, PhantomTrait.class);
registerTraitWithCommand(manager, PolarBearTrait.class);
registerTraitWithCommand(manager, PufferFishTrait.class);
+ registerTraitWithCommand(manager, SpellcasterTrait.class);
registerTraitWithCommand(manager, ShulkerTrait.class);
registerTraitWithCommand(manager, SnowmanTrait.class);
registerTraitWithCommand(manager, TropicalFishTrait.class);
diff --git a/v1_16_R3/src/main/java/net/citizensnpcs/nms/v1_16_R3/util/NMSImpl.java b/v1_16_R3/src/main/java/net/citizensnpcs/nms/v1_16_R3/util/NMSImpl.java
index 44c02a15a..16a714ca4 100644
--- a/v1_16_R3/src/main/java/net/citizensnpcs/nms/v1_16_R3/util/NMSImpl.java
+++ b/v1_16_R3/src/main/java/net/citizensnpcs/nms/v1_16_R3/util/NMSImpl.java
@@ -221,6 +221,7 @@ import net.citizensnpcs.trait.versioned.PolarBearTrait;
import net.citizensnpcs.trait.versioned.PufferFishTrait;
import net.citizensnpcs.trait.versioned.ShulkerTrait;
import net.citizensnpcs.trait.versioned.SnowmanTrait;
+import net.citizensnpcs.trait.versioned.SpellcasterTrait;
import net.citizensnpcs.trait.versioned.TropicalFishTrait;
import net.citizensnpcs.trait.versioned.VillagerTrait;
import net.citizensnpcs.util.EmptyChannel;
@@ -812,6 +813,7 @@ public class NMSImpl implements NMSBridge {
registerTraitWithCommand(manager, PhantomTrait.class);
registerTraitWithCommand(manager, PolarBearTrait.class);
registerTraitWithCommand(manager, PufferFishTrait.class);
+ registerTraitWithCommand(manager, SpellcasterTrait.class);
registerTraitWithCommand(manager, ShulkerTrait.class);
registerTraitWithCommand(manager, SnowmanTrait.class);
registerTraitWithCommand(manager, TropicalFishTrait.class);
diff --git a/v1_17_R1/src/main/java/net/citizensnpcs/nms/v1_17_R1/util/NMSImpl.java b/v1_17_R1/src/main/java/net/citizensnpcs/nms/v1_17_R1/util/NMSImpl.java
index 9e28be8c9..c97b14d6a 100644
--- a/v1_17_R1/src/main/java/net/citizensnpcs/nms/v1_17_R1/util/NMSImpl.java
+++ b/v1_17_R1/src/main/java/net/citizensnpcs/nms/v1_17_R1/util/NMSImpl.java
@@ -224,6 +224,7 @@ import net.citizensnpcs.trait.versioned.PolarBearTrait;
import net.citizensnpcs.trait.versioned.PufferFishTrait;
import net.citizensnpcs.trait.versioned.ShulkerTrait;
import net.citizensnpcs.trait.versioned.SnowmanTrait;
+import net.citizensnpcs.trait.versioned.SpellcasterTrait;
import net.citizensnpcs.trait.versioned.TropicalFishTrait;
import net.citizensnpcs.trait.versioned.VillagerTrait;
import net.citizensnpcs.util.EmptyChannel;
@@ -814,6 +815,7 @@ public class NMSImpl implements NMSBridge {
registerTraitWithCommand(manager, PufferFishTrait.class);
registerTraitWithCommand(manager, ShulkerTrait.class);
registerTraitWithCommand(manager, SnowmanTrait.class);
+ registerTraitWithCommand(manager, SpellcasterTrait.class);
registerTraitWithCommand(manager, TropicalFishTrait.class);
registerTraitWithCommand(manager, VillagerTrait.class);
}
diff --git a/v1_18_R2/src/main/java/net/citizensnpcs/nms/v1_18_R2/util/NMSImpl.java b/v1_18_R2/src/main/java/net/citizensnpcs/nms/v1_18_R2/util/NMSImpl.java
index 58a85e80a..c1ac9c0d0 100644
--- a/v1_18_R2/src/main/java/net/citizensnpcs/nms/v1_18_R2/util/NMSImpl.java
+++ b/v1_18_R2/src/main/java/net/citizensnpcs/nms/v1_18_R2/util/NMSImpl.java
@@ -226,6 +226,7 @@ import net.citizensnpcs.trait.versioned.PolarBearTrait;
import net.citizensnpcs.trait.versioned.PufferFishTrait;
import net.citizensnpcs.trait.versioned.ShulkerTrait;
import net.citizensnpcs.trait.versioned.SnowmanTrait;
+import net.citizensnpcs.trait.versioned.SpellcasterTrait;
import net.citizensnpcs.trait.versioned.TropicalFishTrait;
import net.citizensnpcs.trait.versioned.VillagerTrait;
import net.citizensnpcs.util.EmptyChannel;
@@ -818,6 +819,7 @@ public class NMSImpl implements NMSBridge {
registerTraitWithCommand(manager, PolarBearTrait.class);
registerTraitWithCommand(manager, PufferFishTrait.class);
registerTraitWithCommand(manager, ShulkerTrait.class);
+ registerTraitWithCommand(manager, SpellcasterTrait.class);
registerTraitWithCommand(manager, SnowmanTrait.class);
registerTraitWithCommand(manager, TropicalFishTrait.class);
registerTraitWithCommand(manager, VillagerTrait.class);
diff --git a/v1_19_R2/src/main/java/net/citizensnpcs/nms/v1_19_R2/util/NMSImpl.java b/v1_19_R2/src/main/java/net/citizensnpcs/nms/v1_19_R2/util/NMSImpl.java
index c9fd0684a..f05f929e9 100644
--- a/v1_19_R2/src/main/java/net/citizensnpcs/nms/v1_19_R2/util/NMSImpl.java
+++ b/v1_19_R2/src/main/java/net/citizensnpcs/nms/v1_19_R2/util/NMSImpl.java
@@ -239,6 +239,7 @@ import net.citizensnpcs.trait.versioned.PolarBearTrait;
import net.citizensnpcs.trait.versioned.PufferFishTrait;
import net.citizensnpcs.trait.versioned.ShulkerTrait;
import net.citizensnpcs.trait.versioned.SnowmanTrait;
+import net.citizensnpcs.trait.versioned.SpellcasterTrait;
import net.citizensnpcs.trait.versioned.TropicalFishTrait;
import net.citizensnpcs.trait.versioned.VillagerTrait;
import net.citizensnpcs.util.EmptyChannel;
@@ -841,6 +842,7 @@ public class NMSImpl implements NMSBridge {
registerTraitWithCommand(manager, PhantomTrait.class);
registerTraitWithCommand(manager, PolarBearTrait.class);
registerTraitWithCommand(manager, PufferFishTrait.class);
+ registerTraitWithCommand(manager, SpellcasterTrait.class);
registerTraitWithCommand(manager, ShulkerTrait.class);
registerTraitWithCommand(manager, SnowmanTrait.class);
registerTraitWithCommand(manager, TropicalFishTrait.class);