Skip to content

Commit

Permalink
Review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
me4502 committed Apr 2, 2024
1 parent 898b600 commit ab1fed8
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
"changes": [
"METHOD_REMOVED"
]
}
],
"Removed overridden method": [
},
{
"type": "com.sk89q.worldedit.cli.CLIConfiguration",
"member": "Method com.sk89q.worldedit.cli.CLIConfiguration.loadExtra()",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class CLIBlockCategoryRegistry implements BlockCategoryRegistry {

@Override
public Set<BlockType> getCategorisedByName(String category) {
return CLIWorldEdit.inst.getFileRegistries().getDataFile().blocktags().getOrDefault(category, Collections.emptyList()).stream()
return CLIWorldEdit.inst.getFileRegistries().getDataFile().blockTags().getOrDefault(category, Collections.emptyList()).stream()
.map(BlockType.REGISTRY::get)
.collect(Collectors.toSet());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class CLIItemCategoryRegistry implements ItemCategoryRegistry {

@Override
public Set<ItemType> getCategorisedByName(String category) {
return CLIWorldEdit.inst.getFileRegistries().getDataFile().itemtags().get(category).stream()
return CLIWorldEdit.inst.getFileRegistries().getDataFile().itemTags().get(category).stream()
.map(ItemType.REGISTRY::get)
.collect(Collectors.toSet());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public void setupRegistries() {
context.setRestricted(false);
try {
FuzzyBlockState state = (FuzzyBlockState) WorldEdit.getInstance().getBlockFactory().parseFromInput(
manifestEntry.getValue().defaultstate(),
manifestEntry.getValue().defaultState(),
context
).toImmutableState();
BlockState defaultState = input.getBlockType().getAllStates().get(0);
Expand Down Expand Up @@ -169,13 +169,13 @@ public void setupRegistries() {
}
// Tags
BlockCategory.REGISTRY.clear();
for (String name : fileRegistries.getDataFile().blocktags().keySet()) {
for (String name : fileRegistries.getDataFile().blockTags().keySet()) {
if (BlockCategory.REGISTRY.get(name) == null) {
BlockCategory.REGISTRY.register(name, new BlockCategory(name));
}
}
ItemCategory.REGISTRY.clear();
for (String name : fileRegistries.getDataFile().itemtags().keySet()) {
for (String name : fileRegistries.getDataFile().itemTags().keySet()) {
if (ItemCategory.REGISTRY.get(name) == null) {
ItemCategory.REGISTRY.register(name, new ItemCategory(name));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,20 @@

package com.sk89q.worldedit.cli.data;

import com.google.gson.annotations.SerializedName;

import java.util.List;
import java.util.Map;

public record DataFile(Map<String, List<String>> itemtags,
Map<String, List<String>> blocktags,
Map<String, List<String>> entitytags,
public record DataFile(@SerializedName("itemtags") Map<String, List<String>> itemTags,
@SerializedName("blocktags") Map<String, List<String>> blockTags,
@SerializedName("entitytags") Map<String, List<String>> entityTags,
List<String> items,
List<String> entities,
List<String> biomes,
Map<String, BlockManifest> blocks) {

public record BlockManifest(String defaultstate, Map<String, BlockProperty> properties) {
public record BlockManifest(@SerializedName("defaultstate") String defaultState, Map<String, BlockProperty> properties) {
}

public record BlockProperty(List<String> values, String type) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ public void loadDataFiles() {
Path outputFolder = WorldEdit.getInstance().getWorkingDirectoryPath("cli-data");
Path checkPath = outputFolder.resolve(app.getPlatform().getDataVersion() + "_" + CLI_DATA_VERSION + ".json");

try (Closer closer = Closer.create()) {
try {
Files.createDirectories(outputFolder);

if (!Files.exists(checkPath)) {
URL url = new URL(DATA_FILE_DOWNLOAD_URL + app.getPlatform().getDataVersion() + "/" + CLI_DATA_VERSION);
ReadableByteChannel readableByteChannel = Channels.newChannel(url.openStream());

FileOutputStream fileOutputStream = closer.register(new FileOutputStream(checkPath.toFile()));
fileOutputStream.getChannel().transferFrom(readableByteChannel, 0, Long.MAX_VALUE);
try (var stream = url.openStream()) {
Files.copy(stream, checkPath);
}
}

this.dataFile = gson.fromJson(Files.readString(checkPath), DataFile.class);
Expand Down

0 comments on commit ab1fed8

Please sign in to comment.