Skip to content

Commit

Permalink
Update NPC Metadata usage (#2422)
Browse files Browse the repository at this point in the history
  • Loading branch information
tal5 committed Jan 1, 2023
1 parent 383274b commit f642744
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
Expand Up @@ -258,8 +258,8 @@ public void forceEntitySit(Entity entity, Location location, int retryCount) {
trait.setSmall(true);
trait.setMarker(true);
trait.setVisible(false);
holder.data().set(NPC.NAMEPLATE_VISIBLE_METADATA, false);
holder.data().set(NPC.DEFAULT_PROTECTED_METADATA, true);
holder.data().set(NPC.Metadata.NAMEPLATE_VISIBLE, false);
holder.data().set(NPC.Metadata.DEFAULT_PROTECTED, true);
boolean spawned = holder.spawn(location);
if (!spawned || !holder.isSpawned()) {
if (retryCount >= 4) {
Expand Down
Expand Up @@ -1959,7 +1959,7 @@ else if (object.getLivingEntity() instanceof Steerable) {
// -->
registerSpawnedOnlyTag(ElementTag.class, "is_collidable", (attribute, object) -> {
if (object.isCitizensNPC()) {
return new ElementTag(object.getDenizenNPC().getCitizen().data().get(NPC.COLLIDABLE_METADATA, true));
return new ElementTag(object.getDenizenNPC().getCitizen().data().get(NPC.Metadata.COLLIDABLE, true));
}
return new ElementTag(object.getLivingEntity().isCollidable());
});
Expand Down Expand Up @@ -3387,7 +3387,7 @@ public void adjust(Mechanism mechanism) {
// -->
if (mechanism.matches("collidable") && mechanism.requireBoolean()) {
if (isCitizensNPC()) {
getDenizenNPC().getCitizen().data().setPersistent(NPC.COLLIDABLE_METADATA, mechanism.getValue().asBoolean());
getDenizenNPC().getCitizen().data().setPersistent(NPC.Metadata.COLLIDABLE, mechanism.getValue().asBoolean());
}
else {
getLivingEntity().setCollidable(mechanism.getValue().asBoolean());
Expand Down Expand Up @@ -3547,7 +3547,7 @@ public void adjust(Mechanism mechanism) {
if (mechanism.matches("glowing") && mechanism.requireBoolean()) {
getBukkitEntity().setGlowing(mechanism.getValue().asBoolean());
if (Depends.citizens != null && CitizensAPI.getNPCRegistry().isNPC(getLivingEntity())) {
CitizensAPI.getNPCRegistry().getNPC(getLivingEntity()).data().setPersistent(NPC.GLOWING_METADATA, mechanism.getValue().asBoolean());
CitizensAPI.getNPCRegistry().getNPC(getLivingEntity()).data().setPersistent(NPC.Metadata.GLOWING, mechanism.getValue().asBoolean());
}
}

Expand Down
Expand Up @@ -800,7 +800,7 @@ else if (attribute.startsWith("list", 2)) {
// See <@link command vulnerable>
// -->
tagProcessor.registerTag(ElementTag.class, "invulnerable", (attribute, object) -> {
return new ElementTag(object.getCitizen().data().get(NPC.DEFAULT_PROTECTED_METADATA, true));
return new ElementTag(object.getCitizen().data().get(NPC.Metadata.DEFAULT_PROTECTED, true));
}, "vulnerable");

// <--[tag]
Expand Down Expand Up @@ -980,7 +980,7 @@ else if (attribute.startsWith("list", 2)) {
// Returns whether the NPC is targetable.
// -->
tagProcessor.registerTag(ElementTag.class, "targetable", (attribute, object) -> {
boolean targetable = object.getCitizen().data().get(NPC.TARGETABLE_METADATA, object.getCitizen().data().get(NPC.DEFAULT_PROTECTED_METADATA, true));
boolean targetable = object.getCitizen().data().get(NPC.Metadata.TARGETABLE, object.getCitizen().data().get(NPC.Metadata.DEFAULT_PROTECTED, true));
return new ElementTag(targetable);
});

Expand Down Expand Up @@ -1577,8 +1577,8 @@ public void adjust(Mechanism mechanism) {
((ItemFrame) getEntity()).getItem().setType(mat);
break;
case FALLING_BLOCK:
getCitizen().data().setPersistent(NPC.ITEM_ID_METADATA, mat.name());
getCitizen().data().setPersistent(NPC.ITEM_DATA_METADATA, 0);
getCitizen().data().setPersistent(NPC.Metadata.ITEM_ID, mat.name());
getCitizen().data().setPersistent(NPC.Metadata.ITEM_DATA, 0);
break;
default:
Debug.echoError("NPC is the not an item type!");
Expand Down Expand Up @@ -1715,7 +1715,7 @@ else if (!trait.isSneaking() && mechanism.getValue().asBoolean()) {
// <NPCTag.targetable>
// -->
if (mechanism.matches("targetable") && mechanism.requireBoolean()) {
getCitizen().data().setPersistent(NPC.TARGETABLE_METADATA, mechanism.getValue().asBoolean());
getCitizen().data().setPersistent(NPC.Metadata.TARGETABLE, mechanism.getValue().asBoolean());
}

// <--[mechanism]
Expand Down Expand Up @@ -1807,7 +1807,7 @@ else if (!trait.isSneaking() && mechanism.getValue().asBoolean()) {
// TODO
// -->
if (mechanism.matches("name_visible")) {
getCitizen().data().setPersistent(NPC.NAMEPLATE_VISIBLE_METADATA, mechanism.getValue().asString());
getCitizen().data().setPersistent(NPC.Metadata.NAMEPLATE_VISIBLE, mechanism.getValue().asString());
}

// <--[mechanism]
Expand Down
Expand Up @@ -163,7 +163,7 @@ public void adjust(Mechanism mechanism) {
if (mechanism.matches("item") && mechanism.requireObject(ItemTag.class)) {
ItemStack itemStack = mechanism.valueAsType(ItemTag.class).getItemStack();
if (item.isCitizensNPC()) {
item.getDenizenNPC().getCitizen().data().setPersistent(NPC.ITEM_ID_METADATA, itemStack.getType().name());
item.getDenizenNPC().getCitizen().data().setPersistent(NPC.Metadata.ITEM_ID, itemStack.getType().name());
}
if (isDroppedItem()) {
getDroppedItem().setItemStack(itemStack);
Expand Down
Expand Up @@ -102,7 +102,7 @@ public void execute(ScriptEntry scriptEntry) {
final UUID puuid = Utilities.getEntryPlayer(scriptEntry).getUUID();
for (EntityTag ent : entities) {
if (Depends.citizens != null && CitizensAPI.getNPCRegistry().isNPC(ent.getLivingEntity())) {
CitizensAPI.getNPCRegistry().getNPC(ent.getLivingEntity()).data().setPersistent(NPC.GLOWING_METADATA, shouldGlow);
CitizensAPI.getNPCRegistry().getNPC(ent.getLivingEntity()).data().setPersistent(NPC.Metadata.GLOWING, shouldGlow);
}
if (shouldGlow) {
HashSet<UUID> players = glowViewers.computeIfAbsent(ent.getLivingEntity().getEntityId(), k -> new HashSet<>());
Expand Down

0 comments on commit f642744

Please sign in to comment.