Skip to content

Commit

Permalink
Update DVDs
Browse files Browse the repository at this point in the history
  • Loading branch information
me4502 committed Jul 15, 2019
1 parent 9bd5c6e commit 2ef4539
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,13 @@

package com.sk89q.worldedit.cli;

import com.sk89q.worldedit.cli.data.FileRegistries;
import com.sk89q.worldedit.registry.state.BooleanProperty;
import com.sk89q.worldedit.registry.state.DirectionalProperty;
import com.sk89q.worldedit.registry.state.EnumProperty;
import com.sk89q.worldedit.registry.state.IntegerProperty;
import com.sk89q.worldedit.registry.state.Property;
import com.sk89q.worldedit.util.Direction;
import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.registry.BundledBlockRegistry;

Expand All @@ -32,14 +37,29 @@

public class CLIBlockRegistry extends BundledBlockRegistry {

private Property<?> createProperty(String type, String key, List<?> values) {
switch (type) {
case "int":
return new IntegerProperty(key, (List<Integer>) values);
case "bool":
return new BooleanProperty(key, (List<Boolean>) values);
case "enum":
return new EnumProperty(key, (List<String>) values);
case "dir":
return new DirectionalProperty(key, (List<Direction>) values);
default:
throw new RuntimeException("Failed to create property");
}
}

@Nullable
@Override
public Map<String, ? extends Property<?>> getProperties(BlockType blockType) {
Map<String, List<String>> properties = CLIWorldEdit.inst.getFileRegistries().getDataFile().blocks.get(blockType.getId()).properties;
Map<String, FileRegistries.BlockProperty> properties = CLIWorldEdit.inst.getFileRegistries().getDataFile().blocks.get(blockType.getId()).properties;
Map<String, Property<?>> worldEditProperties = new HashMap<>();

properties.forEach((key, value) -> {
worldEditProperties.put(key, new EnumProperty(key, value));
properties.forEach((name, prop) -> {
worldEditProperties.put(name, createProperty(prop.type, name, prop.values));
});

return worldEditProperties;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,12 @@ public DataFile getDataFile() {

public static class BlockManifest {
public String defaultstate;
public Map<String, List<String>> properties;
public Map<String, BlockProperty> properties;
}

public static class BlockProperty {
public List<String> values;
public String type;
}

public static class DataFile {
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

0 comments on commit 2ef4539

Please sign in to comment.