add setProperty method to the api
This commit is contained in:
parent
16c48043b4
commit
4489e5dacc
3 changed files with 11 additions and 0 deletions
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue