3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-11-17 00:20:09 +01:00

Make property changes more robust (#2962)

Dieser Commit ist enthalten in:
Hannes Greule 2024-11-04 12:22:06 +01:00 committet von GitHub
Ursprung bd94632c47
Commit 7281fa360f
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: B5690EEEBB952194
3 geänderte Dateien mit 21 neuen und 1 gelöschten Zeilen

Datei anzeigen

@ -137,4 +137,9 @@ public class PropertyKey implements Comparable<PropertyKey> {
return Integer.compare(this.id, o.id);
}
@Override
public String toString() {
return "PropertyKey[" + getName() + "]";
}
}

Datei anzeigen

@ -351,7 +351,7 @@ public class BlockState implements BlockStateHolder<BlockState>, Pattern {
BlockState newState = this;
for (Property<?> prop : ot.getProperties()) {
PropertyKey key = prop.getKey();
if (blockType.hasProperty(key)) {
if (blockType.hasPropertyOfType(key, prop.getClass())) {
newState = newState.with(key, other.getState(key));
}
}

Datei anzeigen

@ -247,6 +247,21 @@ public class BlockType implements Keyed, Pattern {
return this.settings.propertiesMapArr.length > ordinal && this.settings.propertiesMapArr[ordinal] != null;
}
/**
* {@return whether this block type has a property with given key of the given type}
*
* @param key the key identifying the property
* @param propertyType the expected type of the property
* @since TODO
*/
public boolean hasPropertyOfType(PropertyKey key, Class<?> propertyType) {
int ordinal = key.getId();
Property<?> property;
return this.settings.propertiesMapArr.length > ordinal
&& (property = this.settings.propertiesMapArr[ordinal]) != null
&& property.getClass() == propertyType;
}
public <V> Property<V> getProperty(PropertyKey key) {
try {
return (Property<V>) this.settings.propertiesMapArr[key.getId()];