Apply list of properties everywhere

Dieser Commit ist enthalten in:
dordsor21 2021-09-21 18:53:37 +01:00
Ursprung cf585c48ae
Commit 268d8cff49
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 1E53E88969FFCF0B
5 geänderte Dateien mit 27 neuen und 12 gelöschten Zeilen

Datei anzeigen

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

Datei anzeigen

@ -200,7 +200,7 @@ public class BlockTypesCache {
public static final BlockType[] values; public static final BlockType[] values;
public static final BlockState[] states; public static final BlockState[] states;
public static final boolean[] ticking; 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<>(); protected static final Set<String> $NAMESPACES = new LinkedHashSet<>();
@ -267,14 +267,6 @@ public class BlockTypesCache {
states = stateList.toArray(new BlockState[stateList.size()]); states = stateList.toArray(new BlockState[stateList.size()]);
ticking = Booleans.toArray(tickList); ticking = Booleans.toArray(tickList);
allProperties = WorldEdit
.getInstance()
.getPlatformManager()
.queryCapability(Capability.GAME_HOOKS)
.getRegistries()
.getBlockRegistry()
.getAllProperties();
} catch (Throwable e) { } catch (Throwable e) {
e.printStackTrace(); e.printStackTrace();
throw new RuntimeException(e); throw new RuntimeException(e);
@ -296,4 +288,24 @@ public class BlockTypesCache {
return existing; 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;
}
}
} }

Datei anzeigen

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

Datei anzeigen

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