commit 930944cc6a3b2f394e925947fad09a1ee824f4c8
parent 0c0963b3e66c40e7959e3e21c93ca24b9b364a87
Author: typable <typable.dev@gmail.com>
Date: Tue, 1 Dec 2020 12:46:24 +0100
Added door sound
Diffstat:
1 file changed, 13 insertions(+), 0 deletions(-)
diff --git a/src/de/typable/minecrafthub/event/DoubleDoorListener.java b/src/de/typable/minecrafthub/event/DoubleDoorListener.java
@@ -5,9 +5,11 @@ import java.util.List;
import org.bukkit.Location;
import org.bukkit.Material;
+import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.block.data.type.Door;
+import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
@@ -30,6 +32,8 @@ public class DoubleDoorListener implements Listener
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event)
{
+ Player player = event.getPlayer();
+
if(event.getAction() == Action.RIGHT_CLICK_BLOCK)
{
if(event.getClickedBlock() != null)
@@ -40,6 +44,11 @@ public class DoubleDoorListener implements Listener
{
List<Block> blockList = getNearbyDoors(block.getLocation());
+ if(player.isSneaking())
+ {
+ return;
+ }
+
if(blockList.isEmpty())
{
return;
@@ -66,6 +75,8 @@ public class DoubleDoorListener implements Listener
stateItem.setBlockData(doorItem);
stateItem.update();
+
+ player.playSound(player.getLocation(), Sound.BLOCK_WOODEN_DOOR_CLOSE, 1F, 1F);
}
if(!door.isOpen() && !doorItem.isOpen())
@@ -74,6 +85,8 @@ public class DoubleDoorListener implements Listener
stateItem.setBlockData(doorItem);
stateItem.update();
+
+ player.playSound(player.getLocation(), Sound.BLOCK_WOODEN_DOOR_OPEN, 1F, 1F);
}
}
}