mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-22 10:36:10 +01:00
Add /npc spellcast
This commit is contained in:
parent
2e3ba077cf
commit
e90096eebe
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
@ -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";
|
||||
|
@ -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}]].<br><br>Valid sounds are {4}.
|
||||
|
@ -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() {
|
||||
|
@ -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() {
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user