mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 21:26:45 +01:00
Send a debug message if category not found
This commit is contained in:
parent
2c060db9c0
commit
a19fa1b92c
@ -26,7 +26,9 @@
|
|||||||
package com.plotsquared.core.plot.flag.types;
|
package com.plotsquared.core.plot.flag.types;
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
|
import com.plotsquared.core.PlotSquared;
|
||||||
import com.sk89q.worldedit.world.block.BlockCategory;
|
import com.sk89q.worldedit.world.block.BlockCategory;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
import com.sk89q.worldedit.world.block.BlockType;
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
@ -97,7 +99,11 @@ public class BlockTypeWrapper {
|
|||||||
|
|
||||||
public BlockCategory getBlockCategory() {
|
public BlockCategory getBlockCategory() {
|
||||||
if (this.blockCategory == null && this.blockCategoryId != null) { // only if name is available
|
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;
|
return this.blockCategory;
|
||||||
}
|
}
|
||||||
@ -117,4 +123,19 @@ public class BlockTypeWrapper {
|
|||||||
return blockCategories.computeIfAbsent(blockCategoryId, BlockTypeWrapper::new);
|
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 New Issue
Block a user