Merge remote-tracking branch 'origin/2.X' into D3v1s0m/2.X

This commit is contained in:
Pyrbu 2023-06-26 12:27:55 +02:00
commit eb1fd0cadd
3 changed files with 11 additions and 0 deletions

View file

@ -3,4 +3,5 @@ package lol.pyr.znpcsplus.api.entity;
public interface PropertyHolder {
<T> T getProperty(EntityProperty<T> key);
boolean hasProperty(EntityProperty<?> key);
<T> void setProperty(EntityProperty<T> key, T value);
}

View file

@ -52,4 +52,9 @@ public class HologramLine implements PropertyHolder {
public boolean hasProperty(EntityProperty<?> key) {
return key.getName().equalsIgnoreCase("name") || key.getName().equalsIgnoreCase("invisible");
}
@Override
public <T> void setProperty(EntityProperty<T> key, T value) {
throw new UnsupportedOperationException("Can't set properties on a hologram");
}
}

View file

@ -129,6 +129,11 @@ public class NpcImpl extends Viewable implements Npc {
return propertyMap.containsKey((EntityPropertyImpl<?>) key);
}
@Override
public <T> void setProperty(EntityProperty<T> key, T value) {
setProperty((EntityPropertyImpl<T>) key, value );
}
public <T> void setProperty(EntityPropertyImpl<T> key, T value) {
if (value == null || value.equals(key.getDefaultValue())) removeProperty(key);
else propertyMap.put(key, value);