diff --git a/pom.xml b/pom.xml index 4b1c61c..ecd7082 100644 --- a/pom.xml +++ b/pom.xml @@ -114,7 +114,7 @@ com.github.Slimefun Slimefun4 - d191599 + b1aae439f3 provided diff --git a/src/main/java/dev/sefiraat/netheopoiesis/api/RecipeTypes.java b/src/main/java/dev/sefiraat/netheopoiesis/api/RecipeTypes.java index 774337f..016d36d 100644 --- a/src/main/java/dev/sefiraat/netheopoiesis/api/RecipeTypes.java +++ b/src/main/java/dev/sefiraat/netheopoiesis/api/RecipeTypes.java @@ -2,9 +2,7 @@ import com.google.common.base.Preconditions; import dev.sefiraat.netheopoiesis.api.interfaces.WorldCrushable; -import dev.sefiraat.netheopoiesis.api.plant.netheos.Flavour; import dev.sefiraat.netheopoiesis.api.plant.netheos.NetheoBalls; -import dev.sefiraat.netheopoiesis.implementation.netheos.NetheoBall; import dev.sefiraat.netheopoiesis.listeners.DropListener; import dev.sefiraat.netheopoiesis.utils.Keys; import dev.sefiraat.netheopoiesis.utils.Theme; @@ -12,7 +10,6 @@ import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; import io.github.thebusybiscuit.slimefun4.libraries.dough.items.CustomItemStack; import org.bukkit.Material; -import org.bukkit.entity.Item; import org.bukkit.inventory.ItemStack; import javax.annotation.Nonnull; diff --git a/src/main/java/dev/sefiraat/netheopoiesis/listeners/PlayerSleepListener.java b/src/main/java/dev/sefiraat/netheopoiesis/listeners/PlayerSleepListener.java index b3e9460..c9bab52 100644 --- a/src/main/java/dev/sefiraat/netheopoiesis/listeners/PlayerSleepListener.java +++ b/src/main/java/dev/sefiraat/netheopoiesis/listeners/PlayerSleepListener.java @@ -5,6 +5,7 @@ import dev.sefiraat.netheopoiesis.utils.WorldUtils; import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag; import org.bukkit.ChatColor; +import org.bukkit.Tag; import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.entity.Player; @@ -45,7 +46,7 @@ public void onSleep(@Nonnull PlayerInteractEvent event) { private boolean validSleepEvent(Action action, World world, Block block) { return action == Action.RIGHT_CLICK_BLOCK && WorldUtils.inNether(world) - && SlimefunTag.BEDS.isTagged(block.getType()) + && Tag.BEDS.isTagged(block.getType()) && Purification.getValue(block.getChunk()) >= 250; } } diff --git a/src/main/java/dev/sefiraat/netheopoiesis/listeners/WaterPlaceListener.java b/src/main/java/dev/sefiraat/netheopoiesis/listeners/WaterPlaceListener.java index 6312ea6..615c0d4 100644 --- a/src/main/java/dev/sefiraat/netheopoiesis/listeners/WaterPlaceListener.java +++ b/src/main/java/dev/sefiraat/netheopoiesis/listeners/WaterPlaceListener.java @@ -4,10 +4,14 @@ import dev.sefiraat.netheopoiesis.utils.WorldUtils; import org.bukkit.GameMode; import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.data.BlockData; +import org.bukkit.block.data.Waterlogged; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import org.bukkit.event.block.Action; import org.bukkit.event.player.PlayerInteractEvent; import javax.annotation.Nonnull; @@ -19,17 +23,38 @@ */ public class WaterPlaceListener implements Listener { + public boolean isValidClick(@Nonnull PlayerInteractEvent event) { + return event.getAction() == Action.RIGHT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_AIR; + } + + public boolean isAllowedToPlaceWater(@Nonnull PlayerInteractEvent event) { + return WorldUtils.inNether(event.getPlayer().getWorld()) + && Purification.getValue(event.getClickedBlock().getChunk()) >= Purification.PLACE_WATER; + } + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onWaterPlace(@Nonnull PlayerInteractEvent event) { final Player player = event.getPlayer(); - if (event.getClickedBlock() != null + final Block clickedBlock = event.getClickedBlock(); + if (clickedBlock != null && event.getItem() != null - && WorldUtils.inNether(player.getWorld()) && player.getInventory().getItemInMainHand().getType() == Material.WATER_BUCKET - && Purification.getValue(event.getClickedBlock().getChunk()) >= Purification.PLACE_WATER + && isAllowedToPlaceWater(event) + && isValidClick(event) ) { event.setCancelled(true); - event.getClickedBlock().getRelative(event.getBlockFace()).setType(Material.WATER); + final BlockData blockData = clickedBlock.getBlockData(); + if (blockData instanceof Waterlogged block + && !block.isWaterlogged() + && !player.isSneaking() + ) { + block.setWaterlogged(true); + } else { + clickedBlock.getRelative(event.getBlockFace()).setType(Material.WATER); + } + + clickedBlock.setBlockData(blockData, true); + if (player.getGameMode() != GameMode.CREATIVE) { event.getItem().setType(Material.BUCKET); }