Fixed breaking blocks in 1.12

This commit is contained in:
Aria Sangarin 2020-02-15 00:29:20 +01:00
parent b7368d7ffd
commit 3e802ee522
2 changed files with 16 additions and 6 deletions

View File

@ -24,6 +24,7 @@ import net.Indyuce.mmocore.manager.CustomBlockManager.BlockInfo;
import net.Indyuce.mmocore.manager.RestrictionManager.BlockPermissions;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.CustomBlock;
import net.mmogroup.mmolib.MMOLib;
public class BlockListener implements Listener {
private static final BlockFace[] order = { BlockFace.UP, BlockFace.DOWN, BlockFace.EAST, BlockFace.NORTH, BlockFace.WEST, BlockFace.SOUTH };
@ -34,7 +35,7 @@ public class BlockListener implements Listener {
if (player.getGameMode() == GameMode.CREATIVE)
return;
String savedData = event.getBlock().getBlockData().getAsString();
String savedData = MMOLib.plugin.getVersion().isStrictlyHigher(1, 12) ? event.getBlock().getBlockData().getAsString() : "";
Block block = event.getBlock();
/*
* if custom mining enabled, check for item breaking restrictions
@ -104,8 +105,12 @@ public class BlockListener implements Listener {
/*
* enable block regen.
*/
if (info.hasRegen())
MMOCore.plugin.mineManager.initialize(info.generateRegenInfo(Bukkit.createBlockData(savedData), block.getLocation()));
if (info.hasRegen()) {
if(MMOLib.plugin.getVersion().isStrictlyHigher(1, 12))
MMOCore.plugin.mineManager.initialize(info.generateRegenInfo(Bukkit.createBlockData(savedData), block.getLocation()));
else
MMOCore.plugin.mineManager.initialize(info.generateRegenInfo(block.getLocation()));
}
}
}

View File

@ -82,11 +82,11 @@ public class CustomBlockManager extends MMOManager {
if(MMOCore.plugin.isMILoaded() && info.getRegen().getCustomRegenBlockID() != 0) {
CustomBlock block = MMOItems.plugin.getCustomBlocks().getBlock(info.getRegen().getCustomRegenBlockID());
info.getLocation().getBlock().setType(block.getType());
info.getLocation().getBlock().setBlockData(block.getBlockData());
if(MMOLib.plugin.getVersion().isStrictlyHigher(1, 12)) info.getLocation().getBlock().setBlockData(block.getBlockData());
}
else info.getLocation().getBlock().setType(info.getRegen().getTemporaryBlock());
if(isPlayerSkull(info.getLocation().getBlock().getType())) {
if(isPlayerSkull(info.getRegen().getBlock())) info.getLocation().getBlock().setBlockData(info.getBlockData());
if(isPlayerSkull(info.getRegen().getBlock()) && MMOLib.plugin.getVersion().isStrictlyHigher(1, 12)) info.getLocation().getBlock().setBlockData(info.getBlockData());
MMOLib.plugin.getNMS().setSkullValue(info.getLocation().getBlock(), info.getRegen().getRegenHeadValue());
}
@ -96,7 +96,8 @@ public class CustomBlockManager extends MMOManager {
}
private void regen(RegenInfo info) {
info.getLocation().getBlock().setBlockData(info.getBlockData());
if(MMOLib.plugin.getVersion().isStrictlyHigher(1, 12))
info.getLocation().getBlock().setBlockData(info.getBlockData());
if(isPlayerSkull(info.getLocation().getBlock().getType()))
MMOLib.plugin.getNMS().setSkullValue(info.getLocation().getBlock(), info.getRegen().getHeadValue());
active.remove(info);
@ -216,6 +217,10 @@ public class CustomBlockManager extends MMOManager {
return new RegenInfo(data, loc, this);
}
public RegenInfo generateRegenInfo(Location loc) {
return new RegenInfo(null, loc, this);
}
public int getCustomBlockID() {
return customBlockId;
}