|
@@ -123,10 +123,14 @@ public class BlockListener implements Listener {
|
|
|
|
|
|
BlockFace direction = event.getDirection();
|
|
BlockFace direction = event.getDirection();
|
|
Block movedBlock;
|
|
Block movedBlock;
|
|
|
|
+ WorldCompatibilityLayer worldCompatibilityLayer = mcMMO.getCompatibilityManager().getWorldCompatibilityLayer();
|
|
|
|
|
|
- for (Block b : event.getBlocks()) {
|
|
|
|
- movedBlock = b.getRelative(direction);
|
|
|
|
- mcMMO.getPlaceStore().setTrue(movedBlock);
|
|
|
|
|
|
+ for (Block block : event.getBlocks()) {
|
|
|
|
+ movedBlock = block.getRelative(direction);
|
|
|
|
+
|
|
|
|
+ if(BlockUtils.isWithinWorldBounds(worldCompatibilityLayer, movedBlock)) {
|
|
|
|
+ mcMMO.getPlaceStore().setTrue(movedBlock);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -151,19 +155,15 @@ public class BlockListener implements Listener {
|
|
|
|
|
|
WorldCompatibilityLayer worldCompatibilityLayer = mcMMO.getCompatibilityManager().getWorldCompatibilityLayer();
|
|
WorldCompatibilityLayer worldCompatibilityLayer = mcMMO.getCompatibilityManager().getWorldCompatibilityLayer();
|
|
|
|
|
|
- World world = movedBlock.getWorld();
|
|
|
|
-
|
|
|
|
//Spigot makes bad things happen in its API
|
|
//Spigot makes bad things happen in its API
|
|
- if(event.getBlock().getY() < worldCompatibilityLayer.getMaxWorldHeight(world) || event.getBlock().getY() >= worldCompatibilityLayer.getMinWorldHeight(world)) {
|
|
|
|
|
|
+ if(BlockUtils.isWithinWorldBounds(worldCompatibilityLayer, movedBlock)) {
|
|
mcMMO.getPlaceStore().setTrue(movedBlock);
|
|
mcMMO.getPlaceStore().setTrue(movedBlock);
|
|
}
|
|
}
|
|
|
|
|
|
for (Block block : event.getBlocks()) {
|
|
for (Block block : event.getBlocks()) {
|
|
- if(block.getY() < worldCompatibilityLayer.getMaxWorldHeight(world) || block.getY() >= worldCompatibilityLayer.getMinWorldHeight(world)) {
|
|
|
|
|
|
+ if(BlockUtils.isWithinWorldBounds(worldCompatibilityLayer, block)) {
|
|
mcMMO.getPlaceStore().setTrue(block.getRelative(direction));
|
|
mcMMO.getPlaceStore().setTrue(block.getRelative(direction));
|
|
}
|
|
}
|
|
-
|
|
|
|
- mcMMO.getPlaceStore().setTrue(movedBlock);
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -180,11 +180,16 @@ public class BlockListener implements Listener {
|
|
if(WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld()))
|
|
if(WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld()))
|
|
return;
|
|
return;
|
|
|
|
|
|
|
|
+
|
|
BlockState blockState = event.getNewState();
|
|
BlockState blockState = event.getNewState();
|
|
|
|
|
|
- if(ExperienceConfig.getInstance().isSnowExploitPrevented() && BlockUtils.shouldBeWatched(blockState))
|
|
|
|
- {
|
|
|
|
- mcMMO.getPlaceStore().setTrue(blockState.getBlock());
|
|
|
|
|
|
+ if(ExperienceConfig.getInstance().isSnowExploitPrevented() && BlockUtils.shouldBeWatched(blockState)) {
|
|
|
|
+ WorldCompatibilityLayer worldCompatibilityLayer = mcMMO.getCompatibilityManager().getWorldCompatibilityLayer();
|
|
|
|
+ Block block = blockState.getBlock();
|
|
|
|
+
|
|
|
|
+ if(BlockUtils.isWithinWorldBounds(worldCompatibilityLayer, block)) {
|
|
|
|
+ mcMMO.getPlaceStore().setTrue(block);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -195,23 +200,19 @@ public class BlockListener implements Listener {
|
|
public void onBlockFormEvent(BlockFormEvent event)
|
|
public void onBlockFormEvent(BlockFormEvent event)
|
|
{
|
|
{
|
|
World world = event.getBlock().getWorld();
|
|
World world = event.getBlock().getWorld();
|
|
- /* WORLD BLACKLIST CHECK */ {
|
|
|
|
- if(WorldBlacklist.isWorldBlacklisted(world))
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
|
|
|
|
- BlockState newState = event.getNewState();
|
|
|
|
|
|
+ /* WORLD BLACKLIST CHECK */
|
|
|
|
+ if(WorldBlacklist.isWorldBlacklisted(world))
|
|
|
|
+ return;
|
|
|
|
|
|
if(ExperienceConfig.getInstance().preventStoneLavaFarming()) {
|
|
if(ExperienceConfig.getInstance().preventStoneLavaFarming()) {
|
|
|
|
+ BlockState newState = event.getNewState();
|
|
WorldCompatibilityLayer worldCompatibilityLayer = mcMMO.getCompatibilityManager().getWorldCompatibilityLayer();
|
|
WorldCompatibilityLayer worldCompatibilityLayer = mcMMO.getCompatibilityManager().getWorldCompatibilityLayer();
|
|
|
|
|
|
- if(event.getBlock().getY() > worldCompatibilityLayer.getMaxWorldHeight(world) || event.getBlock().getY() < worldCompatibilityLayer.getMinWorldHeight(world)) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if(newState.getType() != Material.OBSIDIAN
|
|
|
|
- && ExperienceConfig.getInstance().doesBlockGiveSkillXP(PrimarySkillType.MINING, newState.getBlockData())) {
|
|
|
|
- mcMMO.getPlaceStore().setTrue(newState);
|
|
|
|
|
|
+ if(newState.getType() != Material.OBSIDIAN && ExperienceConfig.getInstance().doesBlockGiveSkillXP(PrimarySkillType.MINING, newState.getBlockData())) {
|
|
|
|
+ if(BlockUtils.isWithinWorldBounds(worldCompatibilityLayer, newState.getBlock())) {
|
|
|
|
+ mcMMO.getPlaceStore().setTrue(newState);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -224,16 +225,23 @@ public class BlockListener implements Listener {
|
|
@EventHandler(priority = EventPriority.MONITOR)
|
|
@EventHandler(priority = EventPriority.MONITOR)
|
|
public void onBlockPlace(BlockPlaceEvent event) {
|
|
public void onBlockPlace(BlockPlaceEvent event) {
|
|
BlockState blockState = event.getBlock().getState();
|
|
BlockState blockState = event.getBlock().getState();
|
|
|
|
+ Block block = blockState.getBlock();
|
|
|
|
|
|
/* Check if the blocks placed should be monitored so they do not give out XP in the future */
|
|
/* Check if the blocks placed should be monitored so they do not give out XP in the future */
|
|
// if (!Tag.LOGS.isTagged(event.getBlockReplacedState().getType()) || !Tag.LOGS.isTagged(event.getBlockPlaced().getType()))
|
|
// if (!Tag.LOGS.isTagged(event.getBlockReplacedState().getType()) || !Tag.LOGS.isTagged(event.getBlockPlaced().getType()))
|
|
- mcMMO.getPlaceStore().setTrue(blockState);
|
|
|
|
|
|
|
|
/* WORLD BLACKLIST CHECK */
|
|
/* WORLD BLACKLIST CHECK */
|
|
- if(WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld())) {
|
|
|
|
|
|
+ if(WorldBlacklist.isWorldBlacklisted(block.getWorld())) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ WorldCompatibilityLayer worldCompatibilityLayer = mcMMO.getCompatibilityManager().getWorldCompatibilityLayer();
|
|
|
|
+
|
|
|
|
+ if(BlockUtils.isWithinWorldBounds(worldCompatibilityLayer, block)) {
|
|
|
|
+ mcMMO.getPlaceStore().setTrue(blockState);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
Player player = event.getPlayer();
|
|
Player player = event.getPlayer();
|
|
|
|
|
|
if (!UserManager.hasPlayerDataKey(player)) {
|
|
if (!UserManager.hasPlayerDataKey(player)) {
|
|
@@ -260,18 +268,21 @@ public class BlockListener implements Listener {
|
|
*/
|
|
*/
|
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
|
public void onBlockMultiPlace(BlockMultiPlaceEvent event) {
|
|
public void onBlockMultiPlace(BlockMultiPlaceEvent event) {
|
|
- for (BlockState replacedBlockState : event.getReplacedBlockStates())
|
|
|
|
- {
|
|
|
|
|
|
+ for (BlockState replacedBlockState : event.getReplacedBlockStates()) {
|
|
BlockState blockState = replacedBlockState.getBlock().getState();
|
|
BlockState blockState = replacedBlockState.getBlock().getState();
|
|
|
|
+ Block block = blockState.getBlock();
|
|
|
|
+
|
|
|
|
+ WorldCompatibilityLayer worldCompatibilityLayer = mcMMO.getCompatibilityManager().getWorldCompatibilityLayer();
|
|
|
|
|
|
/* Check if the blocks placed should be monitored so they do not give out XP in the future */
|
|
/* Check if the blocks placed should be monitored so they do not give out XP in the future */
|
|
- mcMMO.getPlaceStore().setTrue(blockState);
|
|
|
|
|
|
+ if(BlockUtils.isWithinWorldBounds(worldCompatibilityLayer, block)) {
|
|
|
|
+ mcMMO.getPlaceStore().setTrue(blockState);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
|
- public void onBlockGrow(BlockGrowEvent event)
|
|
|
|
- {
|
|
|
|
|
|
+ public void onBlockGrow(BlockGrowEvent event) {
|
|
Block block = event.getBlock();
|
|
Block block = event.getBlock();
|
|
World world = block.getWorld();
|
|
World world = block.getWorld();
|
|
|
|
|
|
@@ -280,10 +291,11 @@ public class BlockListener implements Listener {
|
|
return;
|
|
return;
|
|
|
|
|
|
// Minecraft is dumb, the events still throw when a plant "grows" higher than the max block height. Even though no new block is created
|
|
// Minecraft is dumb, the events still throw when a plant "grows" higher than the max block height. Even though no new block is created
|
|
- if (block.getY() >= world.getMaxHeight())
|
|
|
|
- return;
|
|
|
|
|
|
+ WorldCompatibilityLayer worldCompatibilityLayer = mcMMO.getCompatibilityManager().getWorldCompatibilityLayer();
|
|
|
|
|
|
- mcMMO.getPlaceStore().setFalse(block);
|
|
|
|
|
|
+ if(BlockUtils.isWithinWorldBounds(worldCompatibilityLayer, block)) {
|
|
|
|
+ mcMMO.getPlaceStore().setFalse(block);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|