forked from Upstream/mmocore
can-mine crops age bug fix
This commit is contained in:
parent
d5a6c66c76
commit
d79f972515
@ -1,6 +1,7 @@
|
||||
package net.Indyuce.mmocore.api.block;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
|
||||
import net.Indyuce.mmocore.api.block.BlockInfo.RegeneratingBlock;
|
||||
|
||||
@ -10,8 +11,15 @@ public interface BlockType {
|
||||
// public boolean matches(Block block);
|
||||
|
||||
/*
|
||||
* generates a key used to store the BlockInfo instance in the manager map,
|
||||
* the key depends on the block type to make sure there is no interference
|
||||
* generates a key used to store the BlockInfo instance in the manager map, the
|
||||
* key depends on the block type to make sure there is no interference
|
||||
*/
|
||||
public String generateKey();
|
||||
|
||||
/*
|
||||
* generateKey() determines if the block is handled by that block type,
|
||||
* breakRestrictions(Block) applies some extra break restrictions; returns TRUE
|
||||
* if the block can be broken
|
||||
*/
|
||||
public boolean breakRestrictions(Block block);
|
||||
}
|
||||
|
@ -41,4 +41,9 @@ public class SkullBlockType implements BlockType {
|
||||
public String generateKey() {
|
||||
return "vanilla-skull-" + value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean breakRestrictions(Block block) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -14,8 +14,8 @@ public class VanillaBlockType implements BlockType {
|
||||
private final Material type;
|
||||
|
||||
/*
|
||||
* allows to plant back crops with a custom age so that it does not always
|
||||
* have to full grow again
|
||||
* allows to plant back crops with a custom age so that it does not always have
|
||||
* to full grow again
|
||||
*/
|
||||
private final int age;
|
||||
|
||||
@ -52,4 +52,10 @@ public class VanillaBlockType implements BlockType {
|
||||
public String generateKey() {
|
||||
return "vanilla-block-" + type.name();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean breakRestrictions(Block block) {
|
||||
return age == 0
|
||||
|| (block.getBlockData() instanceof Ageable && ((Ageable) block.getBlockData()).getAge() >= age);
|
||||
}
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ public class BlockListener implements Listener {
|
||||
return;
|
||||
|
||||
BlockInfo info = MMOCore.plugin.mineManager.getInfo(block);
|
||||
if (info == null) {
|
||||
if (info == null || !info.getBlock().breakRestrictions(block)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user