Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
ybw0014 committed Jan 7, 2023
2 parents ead2ba1 + 6013c4c commit 354f4ab
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 9 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
<dependency>
<groupId>com.github.Slimefun</groupId>
<artifactId>Slimefun4</artifactId>
<version>d191599</version>
<version>b1aae439f3</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down
3 changes: 0 additions & 3 deletions src/main/java/dev/sefiraat/netheopoiesis/api/RecipeTypes.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,14 @@

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;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
Expand Down

0 comments on commit 354f4ab

Please sign in to comment.