mirror of
https://github.com/TotalFreedomMC/TF-PlotSquared.git
synced 2024-12-23 00:15:06 +00:00
Send a debug message if category not found
This commit is contained in:
parent
2c060db9c0
commit
a19fa1b92c
1 changed files with 22 additions and 1 deletions
|
@ -26,7 +26,9 @@
|
|||
package com.plotsquared.core.plot.flag.types;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.plotsquared.core.PlotSquared;
|
||||
import com.sk89q.worldedit.world.block.BlockCategory;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
|
@ -97,7 +99,11 @@ public class BlockTypeWrapper {
|
|||
|
||||
public BlockCategory getBlockCategory() {
|
||||
if (this.blockCategory == null && this.blockCategoryId != null) { // only if name is available
|
||||
this.blockCategory = Preconditions.checkNotNull(BlockCategory.REGISTRY.get(this.blockCategoryId));
|
||||
this.blockCategory = BlockCategory.REGISTRY.get(this.blockCategoryId);
|
||||
if (this.blockCategory == null) {
|
||||
PlotSquared.debug("- Block category #" + this.blockCategoryId + " does not exist");
|
||||
this.blockCategory = new NullBlockCategory(this.blockCategoryId);
|
||||
}
|
||||
}
|
||||
return this.blockCategory;
|
||||
}
|
||||
|
@ -117,4 +123,19 @@ public class BlockTypeWrapper {
|
|||
return blockCategories.computeIfAbsent(blockCategoryId, BlockTypeWrapper::new);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prevents exceptions when loading/saving block categories
|
||||
*/
|
||||
private static class NullBlockCategory extends BlockCategory {
|
||||
|
||||
public NullBlockCategory(String id) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <B extends BlockStateHolder<B>> boolean contains(B blockStateHolder) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue