mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2025-01-27 18:41:23 +01:00
Add /npc inventory [player name] and fix some NPEs
This commit is contained in:
parent
2d8267a606
commit
f71e9e47d9
@ -1500,13 +1500,16 @@ public class NPCCommands {
|
||||
|
||||
@Command(
|
||||
aliases = { "npc" },
|
||||
usage = "inventory",
|
||||
usage = "inventory (player name/uuid)",
|
||||
desc = "",
|
||||
modifiers = { "inventory" },
|
||||
min = 1,
|
||||
max = 1,
|
||||
max = 2,
|
||||
permission = "citizens.npc.inventory")
|
||||
public void inventory(CommandContext args, CommandSender sender, NPC npc) {
|
||||
public void inventory(CommandContext args, CommandSender sender, NPC npc, @Arg(1) Player player) {
|
||||
if (player != null) {
|
||||
sender = player;
|
||||
}
|
||||
npc.getOrAddTrait(Inventory.class).openInventory((Player) sender);
|
||||
}
|
||||
|
||||
@ -3320,21 +3323,16 @@ public class NPCCommands {
|
||||
min = 1,
|
||||
max = 2,
|
||||
permission = "citizens.npc.target")
|
||||
public void target(CommandContext args, CommandSender sender, NPC npc) throws CommandUsageException {
|
||||
public void target(CommandContext args, CommandSender sender, NPC npc, @Arg(1) Player player)
|
||||
throws CommandUsageException {
|
||||
if (args.hasFlag('c')) {
|
||||
npc.getNavigator().cancelNavigation();
|
||||
return;
|
||||
}
|
||||
Entity toTarget = args.argsLength() < 2 && sender instanceof Player ? (Player) sender
|
||||
: Bukkit.getPlayer(args.getString(1));
|
||||
if (toTarget == null && args.argsLength() == 2) {
|
||||
toTarget = Bukkit.getEntity(UUID.fromString(args.getString(1)));
|
||||
}
|
||||
if (toTarget != null) {
|
||||
npc.getNavigator().setTarget(toTarget, args.hasFlag('a'));
|
||||
} else {
|
||||
Entity toTarget = player != null ? player : sender instanceof Player ? (Player) sender : null;
|
||||
if (toTarget == null)
|
||||
throw new CommandUsageException();
|
||||
}
|
||||
npc.getNavigator().setTarget(toTarget, args.hasFlag('a'));
|
||||
}
|
||||
|
||||
@Command(
|
||||
|
@ -399,11 +399,11 @@ public class ShopTrait extends Trait {
|
||||
try {
|
||||
NPCShopItem dup = (NPCShopItem) super.clone();
|
||||
dup.cost.clear();
|
||||
for (NPCShopAction src : cost) {
|
||||
for (NPCShopAction src : Lists.newArrayList(cost)) {
|
||||
dup.cost.add(src.clone());
|
||||
}
|
||||
dup.cost.clear();
|
||||
for (NPCShopAction src : result) {
|
||||
dup.result.clear();
|
||||
for (NPCShopAction src : Lists.newArrayList(result)) {
|
||||
dup.result.add(src.clone());
|
||||
}
|
||||
return dup;
|
||||
|
@ -452,8 +452,9 @@ public class NMSImpl implements NMSBridge {
|
||||
|
||||
@Override
|
||||
public void cancelMoveDestination(org.bukkit.entity.Entity entity) {
|
||||
Entity handle = getHandle(entity);
|
||||
MobAI ai = MobAI.from(handle);
|
||||
MobAI ai = MobAI.from(getHandle(entity));
|
||||
if (ai == null)
|
||||
return;
|
||||
MoveControl control = ai != null ? ai.getMoveControl() : null;
|
||||
if (control instanceof EntityMoveControl) {
|
||||
((EntityMoveControl) control).moving = false;
|
||||
|
Loading…
Reference in New Issue
Block a user