mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-04 03:56:41 +00:00
Switch from PropertyKey enum to class (#971)
* Switch from PropertyKey enum to class * Fix generic toArray
This commit is contained in:
@ -185,7 +185,7 @@ public class BlockState implements BlockStateHolder<BlockState>, Pattern {
|
||||
stateId = property.modifyIndex(stateId, index);
|
||||
} else {
|
||||
// suggest
|
||||
PropertyKey key = PropertyKey.get(charSequence);
|
||||
PropertyKey key = PropertyKey.getByName(charSequence);
|
||||
if (key == null || !type.hasProperty(key)) {
|
||||
// Suggest property
|
||||
String input = charSequence.toString();
|
||||
|
@ -181,13 +181,13 @@ public class BlockType implements Keyed, Pattern {
|
||||
}
|
||||
|
||||
public boolean hasProperty(PropertyKey key) {
|
||||
int ordinal = key.ordinal();
|
||||
return this.settings.propertiesMapArr.length > ordinal ? this.settings.propertiesMapArr[ordinal] != null : false;
|
||||
int ordinal = key.getId();
|
||||
return this.settings.propertiesMapArr.length > ordinal && this.settings.propertiesMapArr[ordinal] != null;
|
||||
}
|
||||
|
||||
public <V> Property<V> getProperty(PropertyKey key) {
|
||||
try {
|
||||
return (Property<V>) this.settings.propertiesMapArr[key.ordinal()];
|
||||
return (Property<V>) this.settings.propertiesMapArr[key.getId()];
|
||||
} catch (IndexOutOfBoundsException ignored) {
|
||||
return null;
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ public class BlockTypesCache {
|
||||
// Ensure the properties are registered
|
||||
int maxOrdinal = 0;
|
||||
for (String key : properties.keySet()) {
|
||||
maxOrdinal = Math.max(PropertyKey.getOrCreate(key).ordinal(), maxOrdinal);
|
||||
maxOrdinal = Math.max(PropertyKey.getOrCreate(key).getId(), maxOrdinal);
|
||||
}
|
||||
this.propertiesMapArr = new AbstractProperty[maxOrdinal + 1];
|
||||
int prop_arr_i = 0;
|
||||
@ -70,7 +70,7 @@ public class BlockTypesCache {
|
||||
for (Map.Entry<String, ? extends Property<?>> entry : properties.entrySet()) {
|
||||
PropertyKey key = PropertyKey.getOrCreate(entry.getKey());
|
||||
AbstractProperty<?> property = ((AbstractProperty) entry.getValue()).withOffset(bitOffset);
|
||||
this.propertiesMapArr[key.ordinal()] = property;
|
||||
this.propertiesMapArr[key.getId()] = property;
|
||||
this.propertiesArr[prop_arr_i++] = property;
|
||||
propMap.put(entry.getKey(), property);
|
||||
|
||||
|
Reference in New Issue
Block a user