Skip to content

Commit

Permalink
Merge pull request #4 from Jeshuakrc/dev
Browse files Browse the repository at this point in the history
Issue fix
  • Loading branch information
Jeshuakrc authored Aug 13, 2023
2 parents 8c7d579 + e3acc16 commit 5fe1fd1
Showing 1 changed file with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import com.jkantrell.nbt.tag.StringTag;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.block.data.BlockData;

import java.util.Optional;

public class BukkitChunkReader extends ChunkReader {
Expand All @@ -19,7 +21,7 @@ public BukkitChunkReader(Chunk chunk) {
}


//IMPLEMENTATIONS
//IMPLEMENTATION
@Override
public Optional<Block> blockFromTag(CompoundTag tag) {
Material m = Optional.ofNullable(tag)
Expand All @@ -34,8 +36,16 @@ public Optional<Block> blockFromTag(CompoundTag tag) {
block = new BukkitBlock(m.createBlockData());
return Optional.of(block);
}
String dataString = TagInterpreter.COMPOUND.interpretBlockDataString(properties);
block = new BukkitBlock(m.createBlockData(dataString));

//IllegalArgumentException might be thrown if block data is not compatible with current version of Minecraft
//In such case, return plain block with no data
try {
String dataString = TagInterpreter.COMPOUND.interpretBlockDataString(properties);
block = new BukkitBlock(m.createBlockData(dataString));
} catch (IllegalArgumentException e) {
block = new BukkitBlock(m.createBlockData());
}

return Optional.of(block);
}
@Override
Expand Down

0 comments on commit 5fe1fd1

Please sign in to comment.