mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2025-01-29 19:41:50 +01:00
Add /npc item
This commit is contained in:
parent
ecbd2efe28
commit
ed42a3cadd
@ -33,6 +33,7 @@ import net.citizensnpcs.api.util.Paginator;
|
||||
import net.citizensnpcs.npc.EntityControllers;
|
||||
import net.citizensnpcs.npc.NPCSelector;
|
||||
import net.citizensnpcs.npc.Template;
|
||||
import net.citizensnpcs.npc.entity.nonliving.FallingBlockController.FallingBlockNPC;
|
||||
import net.citizensnpcs.trait.Age;
|
||||
import net.citizensnpcs.trait.Anchors;
|
||||
import net.citizensnpcs.trait.Controllable;
|
||||
@ -58,6 +59,7 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.BlockCommandSender;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -68,6 +70,7 @@ import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Horse.Color;
|
||||
import org.bukkit.entity.Horse.Style;
|
||||
import org.bukkit.entity.Horse.Variant;
|
||||
import org.bukkit.entity.ItemFrame;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Ocelot;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -561,6 +564,37 @@ public class NPCCommands {
|
||||
Messaging.send(sender, npc.getId());
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "npc" },
|
||||
usage = "item [item]",
|
||||
desc = "Sets the NPC's item",
|
||||
modifiers = { "item", },
|
||||
min = 1,
|
||||
max = 2,
|
||||
flags = "",
|
||||
permission = "citizens.npc.item")
|
||||
@Requirements(selected = true, ownership = true, types = { EntityType.DROPPED_ITEM, EntityType.ITEM_FRAME,
|
||||
EntityType.FALLING_BLOCK })
|
||||
public void item(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||
Material mat = Material.getMaterial(args.getString(1));
|
||||
if (mat == null)
|
||||
throw new CommandException(Messages.UNKNOWN_MATERIAL);
|
||||
switch (npc.getEntity().getType()) {
|
||||
case DROPPED_ITEM:
|
||||
((org.bukkit.entity.Item) npc.getEntity()).getItemStack().setType(mat);
|
||||
break;
|
||||
case ITEM_FRAME:
|
||||
((ItemFrame) npc.getEntity()).getItem().setType(mat);
|
||||
break;
|
||||
case FALLING_BLOCK:
|
||||
((FallingBlockNPC) npc.getEntity()).setType(mat);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
Messaging.sendTr(sender, Messages.ITEM_SET, Util.prettyEnum(mat));
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "npc" },
|
||||
usage = "leashable",
|
||||
|
@ -10,9 +10,11 @@ import net.minecraft.server.v1_7_R1.EntityFallingBlock;
|
||||
import net.minecraft.server.v1_7_R1.World;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftFallingSand;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.util.CraftMagicNumbers;
|
||||
import org.bukkit.entity.FallingBlock;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
@ -105,5 +107,14 @@ public class FallingBlockController extends MobEntityController {
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
public void setType(Material material) {
|
||||
EntityFallingBlock e = (EntityFallingBlock) entity;
|
||||
e.id = CraftMagicNumbers.getBlock(material);
|
||||
if (npc.isSpawned()) {
|
||||
npc.despawn();
|
||||
npc.spawn(npc.getStoredLocation());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -102,6 +102,7 @@ public class Messages {
|
||||
public static final String INVALID_SKELETON_TYPE = "citizens.commands.npc.skeletontype.invalid-type";
|
||||
public static final String INVALID_SPAWN_LOCATION = "citizens.commands.npc.create.invalid-location";
|
||||
public static final String INVALID_TRIGGER_TELEPORT_FORMAT = "citizens.editors.waypoints.triggers.teleport.invalid-format";
|
||||
public static final String ITEM_SET = "citizens.commands.npc.item.item-set";
|
||||
public static final String LEASHABLE_SET = "citizens.commands.npc.leashable.set";
|
||||
public static final String LEASHABLE_STOPPED = "citizens.commands.npc.leashable.stopped";
|
||||
public static final String LINEAR_WAYPOINT_EDITOR_ADDED_WAYPOINT = "citizens.editors.waypoints.linear.added-waypoint";
|
||||
@ -229,6 +230,7 @@ public class Messages {
|
||||
public static final String TRAITS_FAILED_TO_CHANGE = "citizens.commands.trait.failed-to-change";
|
||||
public static final String TRAITS_REMOVED = "citizens.commands.trait.removed";
|
||||
public static final String UNKNOWN_COMMAND = "citizens.commands.unknown-command";
|
||||
public static final String UNKNOWN_MATERIAL = "citizens.commands.npc.item.unknown-material";
|
||||
public static final String VULNERABLE_SET = "citizens.commands.npc.vulnerable.set";
|
||||
public static final String VULNERABLE_STOPPED = "citizens.commands.npc.vulnerable.stopped";
|
||||
public static final String WAYPOINT_PROVIDER_SET = "citizens.waypoints.set-provider";
|
||||
|
@ -51,6 +51,8 @@ citizens.commands.npc.horse.describe=The horse''s color is [[{0}]], the type is
|
||||
citizens.commands.npc.horse.invalid-color=Invalid horse color given. Valid colors are: [[{0}]].
|
||||
citizens.commands.npc.horse.invalid-type=Invalid horse type given. Valid types are: [[{0}]].
|
||||
citizens.commands.npc.horse.invalid-style=Invalid horse style given. Valid styles are: [[{0}]].
|
||||
citizens.commands.npc.item.item-set=NPC item set to [[{0}]].
|
||||
citizens.commands.npc.item.unknown-material=Unknown material given.
|
||||
citizens.commands.npc.leashable.set=[[{0}]] is now leashable.
|
||||
citizens.commands.npc.leashable.stopped=[[{0}]] is no longer leashable.
|
||||
citizens.commands.npc.lookclose.set=[[{0}]] will now rotate when players are nearby.
|
||||
|
Loading…
Reference in New Issue
Block a user