Skip to content

Commit

Permalink
Drop owner string from Owner trait
Browse files Browse the repository at this point in the history
  • Loading branch information
fullwall committed Oct 12, 2021
1 parent 780899c commit 4ecf090
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions main/src/main/java/net/citizensnpcs/commands/NPCCommands.java
Expand Up @@ -1418,7 +1418,7 @@ public void ocelot(CommandContext args, CommandSender sender, NPC npc) throws Co

@Command(
aliases = { "npc" },
usage = "owner [name]",
usage = "owner [uuid]",
desc = "Set the owner of an NPC",
modifiers = { "owner" },
min = 1,
Expand All @@ -1427,15 +1427,15 @@ public void ocelot(CommandContext args, CommandSender sender, NPC npc) throws Co
public void owner(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
Owner ownerTrait = npc.getOrAddTrait(Owner.class);
if (args.argsLength() == 1) {
Messaging.sendTr(sender, Messages.NPC_OWNER, npc.getName(), ownerTrait.getOwner());
Messaging.sendTr(sender, Messages.NPC_OWNER, npc.getName(), ownerTrait.getOwnerId());
return;
}
String name = args.getString(1);
if (ownerTrait.isOwnedBy(name))
throw new CommandException(Messages.ALREADY_OWNER, name, npc.getName());
ownerTrait.setOwner(name);
boolean serverOwner = name.equalsIgnoreCase(Owner.SERVER);
Messaging.sendTr(sender, serverOwner ? Messages.OWNER_SET_SERVER : Messages.OWNER_SET, npc.getName(), name);
UUID uuid = args.getString(1).equals("SERVER") ? null : UUID.fromString(args.getString(1));
if (ownerTrait.isOwnedBy(uuid))
throw new CommandException(Messages.ALREADY_OWNER, uuid, npc.getName());
ownerTrait.setOwner(uuid);
boolean serverOwner = uuid == null;
Messaging.sendTr(sender, serverOwner ? Messages.OWNER_SET_SERVER : Messages.OWNER_SET, npc.getName(), uuid);
}

@Command(
Expand Down

0 comments on commit 4ecf090

Please sign in to comment.