added single type constructor to block component

This commit is contained in:
Niklas 2020-06-28 01:41:40 +02:00
parent bfa145b862
commit d7f1759502

View File

@ -5,6 +5,7 @@ import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet;
import java.util.Set; import java.util.Set;
interface CheckFunction { interface CheckFunction {
@ -36,6 +37,12 @@ public class BlockComponent {
this.customCheckFunction = customCheckFunction; this.customCheckFunction = customCheckFunction;
} }
public BlockComponent(Material type){
this.blocks = new HashSet<>();
this.blocks.add(type);
this.mode = BlockComponentMode.SET;
}
public boolean isValidBlock(Location location){ public boolean isValidBlock(Location location){
if(this.mode == BlockComponentMode.CUSTOM){ if(this.mode == BlockComponentMode.CUSTOM){
return this.customCheckFunction.apply(location); return this.customCheckFunction.apply(location);