Skip to content

Commit

Permalink
Use door matcher for door sounds
Browse files Browse the repository at this point in the history
  • Loading branch information
pop4959 committed Feb 8, 2024
1 parent 184cb1c commit 3b117f4
Showing 1 changed file with 15 additions and 38 deletions.
53 changes: 15 additions & 38 deletions src/main/java/com/griefcraft/modules/doors/DoorsModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -203,44 +203,21 @@ private void changeDoorStates(LWCProtectionInteractEvent event, boolean allowDoo
door.setBlockData(doorBlockData);

// make the correct door sound
switch (door.getType()) {
case OAK_DOOR:
case SPRUCE_DOOR:
case BIRCH_DOOR:
case JUNGLE_DOOR:
case ACACIA_DOOR:
case DARK_OAK_DOOR:
door.getWorld().playSound(door.getLocation(),
doorIsOpen ? Sound.BLOCK_WOODEN_DOOR_CLOSE : Sound.BLOCK_WOODEN_DOOR_OPEN, 1, 1);
break;
case IRON_DOOR:
door.getWorld().playSound(door.getLocation(),
doorIsOpen ? Sound.BLOCK_IRON_DOOR_CLOSE : Sound.BLOCK_IRON_DOOR_OPEN, 1, 1);
break;
case OAK_TRAPDOOR:
case SPRUCE_TRAPDOOR:
case BIRCH_TRAPDOOR:
case JUNGLE_TRAPDOOR:
case ACACIA_TRAPDOOR:
case DARK_OAK_TRAPDOOR:
door.getWorld().playSound(door.getLocation(),
doorIsOpen ? Sound.BLOCK_WOODEN_TRAPDOOR_CLOSE : Sound.BLOCK_WOODEN_TRAPDOOR_OPEN, 1, 1);
break;
case IRON_TRAPDOOR:
door.getWorld().playSound(door.getLocation(),
doorIsOpen ? Sound.BLOCK_IRON_TRAPDOOR_CLOSE : Sound.BLOCK_IRON_TRAPDOOR_OPEN, 1, 1);
break;
case OAK_FENCE_GATE:
case SPRUCE_FENCE_GATE:
case BIRCH_FENCE_GATE:
case JUNGLE_FENCE_GATE:
case ACACIA_FENCE_GATE:
case DARK_OAK_FENCE_GATE:
door.getWorld().playSound(door.getLocation(),
doorIsOpen ? Sound.BLOCK_FENCE_GATE_CLOSE : Sound.BLOCK_FENCE_GATE_OPEN, 1, 1);
break;
default:
break;
if (DoorMatcher.WOODEN_DOORS.contains(door.getType())) {
door.getWorld().playSound(door.getLocation(),
doorIsOpen ? Sound.BLOCK_WOODEN_DOOR_CLOSE : Sound.BLOCK_WOODEN_DOOR_OPEN, 1, 1);
} else if (Material.IRON_DOOR.equals(door.getType())) {
door.getWorld().playSound(door.getLocation(),
doorIsOpen ? Sound.BLOCK_IRON_DOOR_CLOSE : Sound.BLOCK_IRON_DOOR_OPEN, 1, 1);
} else if (DoorMatcher.WOODEN_TRAP_DOORS.contains(door.getType())) {
door.getWorld().playSound(door.getLocation(),
doorIsOpen ? Sound.BLOCK_WOODEN_TRAPDOOR_CLOSE : Sound.BLOCK_WOODEN_TRAPDOOR_OPEN, 1, 1);
} else if (Material.IRON_TRAPDOOR.equals(door.getType())) {
door.getWorld().playSound(door.getLocation(),
doorIsOpen ? Sound.BLOCK_IRON_TRAPDOOR_CLOSE : Sound.BLOCK_IRON_TRAPDOOR_OPEN, 1, 1);
} else if (DoorMatcher.FENCE_GATES.contains(door.getType())) {
door.getWorld().playSound(door.getLocation(),
doorIsOpen ? Sound.BLOCK_FENCE_GATE_CLOSE : Sound.BLOCK_FENCE_GATE_OPEN, 1, 1);
}
}
}
Expand Down

0 comments on commit 3b117f4

Please sign in to comment.