Skip to content
This repository has been archived by the owner on Jan 20, 2024. It is now read-only.

Commit

Permalink
Sound: hotfix type glass knocking
Browse files Browse the repository at this point in the history
  • Loading branch information
TheFaser committed Oct 7, 2023
1 parent 7ccce39 commit 8bb1a3e
Showing 1 changed file with 44 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,53 @@
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;

import java.util.ArrayList;
import java.util.List;

import static net.flectone.managers.FileManager.config;

public class PlayerGlassKnockingListener implements Listener {

private static final List<String> GLASSES = new ArrayList<>();

static {
GLASSES.add(Material.GLASS.name());
GLASSES.add(Material.BLACK_STAINED_GLASS.name());
GLASSES.add(Material.BLUE_STAINED_GLASS.name());
GLASSES.add(Material.BROWN_STAINED_GLASS.name());
GLASSES.add(Material.CYAN_STAINED_GLASS.name());
GLASSES.add(Material.GRAY_STAINED_GLASS.name());
GLASSES.add(Material.GREEN_STAINED_GLASS.name());
GLASSES.add(Material.LIGHT_BLUE_STAINED_GLASS.name());
GLASSES.add(Material.LIGHT_GRAY_STAINED_GLASS.name());
GLASSES.add(Material.LIME_STAINED_GLASS.name());
GLASSES.add(Material.MAGENTA_STAINED_GLASS.name());
GLASSES.add(Material.ORANGE_STAINED_GLASS.name());
GLASSES.add(Material.PINK_STAINED_GLASS.name());
GLASSES.add(Material.PURPLE_STAINED_GLASS.name());
GLASSES.add(Material.RED_STAINED_GLASS.name());
GLASSES.add(Material.WHITE_STAINED_GLASS.name());
GLASSES.add(Material.YELLOW_STAINED_GLASS.name());
GLASSES.add(Material.GLASS_PANE.name());
GLASSES.add(Material.BLACK_STAINED_GLASS_PANE.name());
GLASSES.add(Material.BLUE_STAINED_GLASS_PANE.name());
GLASSES.add(Material.BROWN_STAINED_GLASS_PANE.name());
GLASSES.add(Material.CYAN_STAINED_GLASS_PANE.name());
GLASSES.add(Material.GRAY_STAINED_GLASS_PANE.name());
GLASSES.add(Material.GREEN_STAINED_GLASS_PANE.name());
GLASSES.add(Material.LIGHT_BLUE_STAINED_GLASS_PANE.name());
GLASSES.add(Material.LIGHT_GRAY_STAINED_GLASS_PANE.name());
GLASSES.add(Material.LIME_STAINED_GLASS_PANE.name());
GLASSES.add(Material.MAGENTA_STAINED_GLASS_PANE.name());
GLASSES.add(Material.ORANGE_STAINED_GLASS_PANE.name());
GLASSES.add(Material.PINK_STAINED_GLASS_PANE.name());
GLASSES.add(Material.PURPLE_STAINED_GLASS_PANE.name());
GLASSES.add(Material.RED_STAINED_GLASS_PANE.name());
GLASSES.add(Material.WHITE_STAINED_GLASS_PANE.name());
GLASSES.add(Material.YELLOW_STAINED_GLASS_PANE.name());
GLASSES.add("TINTED_GLASS");
}

@EventHandler
public void onGlassKnockingEvent(PlayerInteractEvent event) {
if (!config.getBoolean("player.glass-knocking.enable")) return;
Expand All @@ -22,7 +65,7 @@ public void onGlassKnockingEvent(PlayerInteractEvent event) {

if (!player.isSneaking()
|| block == null
|| !(block.getType().equals(Material.GLASS) || block.getType().equals(Material.GLASS_PANE))) return;
|| !(GLASSES.contains(block.getType().name()))) return;

ObjectUtil.playSound(player, block.getLocation(), "glass-knocking");
}
Expand Down

0 comments on commit 8bb1a3e

Please sign in to comment.