Implement getAllProperties to code and adapters

This commit is contained in:
dordsor21 2021-09-20 16:00:50 +01:00
parent 35e0a47beb
commit 017a28b3dd
No known key found for this signature in database
GPG Key ID: 1E53E88969FFCF0B
5 changed files with 32 additions and 0 deletions

View File

@ -159,5 +159,14 @@ public class BukkitBlockRegistry extends BundledBlockRegistry {
}
return blocks;
}
@Override
public Map<String, ? extends Property<?>> getAllProperties() {
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
if (adapter != null) {
return adapter.getAllProperties();
}
return super.getAllProperties();
}
//FAWE end
}

View File

@ -200,6 +200,7 @@ public class BlockTypesCache {
public static final BlockType[] values;
public static final BlockState[] states;
public static final boolean[] ticking;
public static final Map<String, ? extends Property<?>> allProperties;
protected static final Set<String> $NAMESPACES = new LinkedHashSet<>();
@ -266,6 +267,14 @@ public class BlockTypesCache {
states = stateList.toArray(new BlockState[stateList.size()]);
ticking = Booleans.toArray(tickList);
allProperties = WorldEdit
.getInstance()
.getPlatformManager()
.queryCapability(Capability.GAME_HOOKS)
.getRegistries()
.getBlockRegistry()
.getAllProperties();
} catch (Throwable e) {
e.printStackTrace();
throw new RuntimeException(e);

View File

@ -96,5 +96,12 @@ public interface BlockRegistry {
default Collection<String> values() {
return Collections.emptyList();
}
/**
* Get an unmodifiable map of all block properties
*
* @return a map of states where the key is the property's ID
*/
Map<String, ? extends Property<?>> getAllProperties();
//FAWE end
}

View File

@ -80,4 +80,11 @@ public class BundledBlockRegistry implements BlockRegistry {
return OptionalInt.empty();
}
//FAWE start
@Override
public Map<String, ? extends Property<?>> getAllProperties() {
return Collections.emptyMap(); // Oof
}
//FAWE end
}