Apply list of properties everywhere

This commit is contained in:
dordsor21 2021-09-21 18:53:37 +01:00
parent cf585c48ae
commit 268d8cff49
No known key found for this signature in database
GPG Key ID: 1E53E88969FFCF0B
5 changed files with 27 additions and 12 deletions

View File

@ -33,6 +33,7 @@ import org.bukkit.block.data.BlockData;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.OptionalInt;
@ -161,7 +162,7 @@ public class BukkitBlockRegistry extends BundledBlockRegistry {
}
@Override
public Map<String, ? extends Property<?>> getAllProperties() {
public Map<String, ? extends List<Property<?>>> getAllProperties() {
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
if (adapter != null) {
return adapter.getAllProperties();

View File

@ -200,7 +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;
private static final Map<String, List<Property<?>>> allProperties = new HashMap<>();
protected static final Set<String> $NAMESPACES = new LinkedHashSet<>();
@ -267,14 +267,6 @@ 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);
@ -296,4 +288,24 @@ public class BlockTypesCache {
return existing;
}
/**
* Get a list of all block properties available.
*
* @return map of string key against property of all block properties available
*/
public static Map<String, List<Property<?>>> getAllProperties() {
synchronized (allProperties) {
if (allProperties.size() == 0) {
allProperties.putAll(WorldEdit
.getInstance()
.getPlatformManager()
.queryCapability(Capability.GAME_HOOKS)
.getRegistries()
.getBlockRegistry()
.getAllProperties());
}
return allProperties;
}
}
}

View File

@ -27,6 +27,7 @@ import com.sk89q.worldedit.world.block.BlockType;
import javax.annotation.Nullable;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.OptionalInt;
@ -102,6 +103,6 @@ public interface BlockRegistry {
*
* @return a map of states where the key is the property's ID
*/
Map<String, ? extends Property<?>> getAllProperties();
Map<String, ? extends List<Property<?>>> getAllProperties();
//FAWE end
}

View File

@ -29,6 +29,7 @@ import com.sk89q.worldedit.world.block.BlockType;
import javax.annotation.Nullable;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.OptionalInt;
@ -82,7 +83,7 @@ public class BundledBlockRegistry implements BlockRegistry {
//FAWE start
@Override
public Map<String, ? extends Property<?>> getAllProperties() {
public Map<String, ? extends List<Property<?>>> getAllProperties() {
return Collections.emptyMap(); // Oof
}
//FAWE end