mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2025-02-16 20:31:30 +01:00
Add /npc setequipment
This commit is contained in:
parent
130dc42e5f
commit
a551fe4890
@ -718,8 +718,6 @@ public class EventListen implements Listener {
|
||||
Method getAcceleration = kbc.getMethod("getAcceleration");
|
||||
handlers.register(new RegisteredListener(new Listener() {
|
||||
}, (listener, event) -> {
|
||||
if (NPCKnockbackEvent.getHandlerList().getRegisteredListeners().length == 0)
|
||||
return;
|
||||
try {
|
||||
Entity entity = (Entity) getEntity.invoke(event);
|
||||
if (!(entity instanceof NPCHolder))
|
||||
|
@ -78,6 +78,8 @@ import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.api.npc.NPC.NPCUpdate;
|
||||
import net.citizensnpcs.api.npc.NPCRegistry;
|
||||
import net.citizensnpcs.api.trait.Trait;
|
||||
import net.citizensnpcs.api.trait.trait.Equipment;
|
||||
import net.citizensnpcs.api.trait.trait.Equipment.EquipmentSlot;
|
||||
import net.citizensnpcs.api.trait.trait.Inventory;
|
||||
import net.citizensnpcs.api.trait.trait.MobType;
|
||||
import net.citizensnpcs.api.trait.trait.Owner;
|
||||
@ -1088,7 +1090,10 @@ public class NPCCommands {
|
||||
max = -1,
|
||||
permission = "citizens.npc.hologram")
|
||||
public void hologram(CommandContext args, CommandSender sender, NPC npc,
|
||||
@Arg(value = 1, completions = { "add", "set", "remove", "clear", "lineheight", "direction", "margintop", "marginbottom" }) String action)
|
||||
@Arg(
|
||||
value = 1,
|
||||
completions = { "add", "set", "remove", "clear", "lineheight", "direction", "margintop",
|
||||
"marginbottom" }) String action)
|
||||
throws CommandException {
|
||||
HologramTrait trait = npc.getOrAddTrait(HologramTrait.class);
|
||||
if (args.argsLength() == 1) {
|
||||
@ -2621,6 +2626,27 @@ public class NPCCommands {
|
||||
}
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "npc" },
|
||||
usage = "setequipment [slot] [item]",
|
||||
desc = "Sets equipment via commands",
|
||||
modifiers = { "setequipment" },
|
||||
min = 2,
|
||||
max = 3,
|
||||
permission = "citizens.npc.setequipment")
|
||||
public void setequipment(CommandContext args, CommandSender sender, NPC npc, @Arg(1) EquipmentSlot slot,
|
||||
@Arg(2) ItemStack item) throws CommandException {
|
||||
if (slot == null)
|
||||
throw new CommandUsageException();
|
||||
if (item == null && args.argsLength() == 3 && args.getString(2).equalsIgnoreCase("hand")) {
|
||||
if (!(sender instanceof Player))
|
||||
throw new ServerCommandException();
|
||||
item = ((Player) sender).getItemInHand().clone();
|
||||
}
|
||||
npc.getOrAddTrait(Equipment.class).set(slot, item);
|
||||
Messaging.sendTr(sender, Messages.EQUIPMENT_SET, slot, item);
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "npc" },
|
||||
usage = "sheep (--color [color]) (--sheared [sheared])",
|
||||
|
@ -104,6 +104,7 @@ public class Messages {
|
||||
public static final String EQUIPMENT_EDITOR_BEGIN = "citizens.editors.equipment.begin";
|
||||
public static final String EQUIPMENT_EDITOR_END = "citizens.editors.equipment.end";
|
||||
public static final String EQUIPMENT_EDITOR_SHEEP_COLOURED = "citizens.editors.equipment.sheep-coloured";
|
||||
public static final String EQUIPMENT_SET = "citizens.commands.npc.setequipment.set";
|
||||
public static final String ERROR_CLEARING_GOALS = "citizens.nms-errors.clearing-goals";
|
||||
public static final String ERROR_GETTING_FIELD = "citizens.nms-errors.getting-field";
|
||||
public static final String ERROR_GETTING_ID_MAPPING = "citizens.nms-errors.getting-id-mapping";
|
||||
@ -156,10 +157,10 @@ public class Messages {
|
||||
public static final String HOLOGRAM_LINE_HEIGHT_SET = "citizens.commands.npc.hologram.line-height-set";
|
||||
public static final String HOLOGRAM_LINE_REMOVED = "citizens.commands.npc.hologram.line-removed";
|
||||
public static final String HOLOGRAM_LINE_SET = "citizens.commands.npc.hologram.text-set";
|
||||
public static final String HOLOGRAM_TEXT_MISSING = "citizens.commands.npc.hologram.text-missing";
|
||||
public static final String HOLOGRAM_TEXT_REMOVED = "citizens.commands.npc.hologram.text-removed";
|
||||
public static final String HOLOGRAM_MARGIN_MISSING = "citizens.commands.npc.hologram.margin-missing";
|
||||
public static final String HOLOGRAM_MARGIN_SET = "citizens.commands.npc.hologram.margin-set";
|
||||
public static final String HOLOGRAM_TEXT_MISSING = "citizens.commands.npc.hologram.text-missing";
|
||||
public static final String HOLOGRAM_TEXT_REMOVED = "citizens.commands.npc.hologram.text-removed";
|
||||
public static final String HOME_TRAIT_DELAY_SET = "citizens.commands.npc.home.delay-set";
|
||||
public static final String HOME_TRAIT_DISTANCE_SET = "citizens.commands.npc.home.distance-set";
|
||||
public static final String HOME_TRAIT_LOCATION_SET = "citizens.commands.npc.home.home-set";
|
||||
|
@ -272,6 +272,7 @@ citizens.commands.npc.remove.removed=You permanently removed [[{0}]] ID [[{1}]]
|
||||
citizens.commands.npc.rename.renamed=You renamed [[{0}]] to [[{1}]].
|
||||
citizens.commands.npc.respawn.delay-set=Respawn delay set to [[{0}]] ticks.
|
||||
citizens.commands.npc.respawn.describe=Respawn delay is currently [[{0}]] ticks.
|
||||
citizens.commands.npc.setequipment.set=Set [[{0}]] to [[{1}]].
|
||||
citizens.commands.npc.select.already-selected=You already have that NPC selected.
|
||||
citizens.commands.npc.script.invalid-file=Unknown or unavailable script ''[[{0}]]''.
|
||||
citizens.commands.npc.scoreboard.added-tags=Added these tags: [[{0}]].
|
||||
|
Loading…
Reference in New Issue
Block a user