Skip to content

Commit

Permalink
Simplify owner trait slightly
Browse files Browse the repository at this point in the history
  • Loading branch information
fullwall committed Jun 11, 2023
1 parent 0f027c6 commit 87110a9
Showing 1 changed file with 3 additions and 18 deletions.
21 changes: 3 additions & 18 deletions src/main/java/net/citizensnpcs/api/trait/trait/Owner.java
Expand Up @@ -6,17 +6,17 @@
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;

import net.citizensnpcs.api.exception.NPCLoadException;
import net.citizensnpcs.api.persistence.Persist;
import net.citizensnpcs.api.trait.Trait;
import net.citizensnpcs.api.trait.TraitName;
import net.citizensnpcs.api.util.DataKey;

/**
* Represents the owner of an NPC.
*/
@TraitName("owner")
public class Owner extends Trait {
private UUID uuid = null;
@Persist
private UUID uuid;

public Owner() {
super("owner");
Expand Down Expand Up @@ -66,21 +66,6 @@ public boolean isOwnedBy(UUID other) {
return uuid == null ? other == null : uuid.equals(other);
}

@Override
public void load(DataKey key) throws NPCLoadException {
if (key.keyExists("uuid") && !key.getString("uuid").isEmpty()) {
uuid = UUID.fromString(key.getString("uuid"));
} else {
uuid = null;
}
key.removeKey("owner");
}

@Override
public void save(DataKey key) {
key.setString("uuid", uuid == null ? "" : uuid.toString());
}

public void setOwner(CommandSender sender) {
if (sender instanceof OfflinePlayer) {
this.uuid = ((OfflinePlayer) sender).getUniqueId();
Expand Down

0 comments on commit 87110a9

Please sign in to comment.