-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #53 from Alathra/fix/disable-trapdoor-flipping-in-…
…spawn feat: disable trapdoor flipping in spawn
- Loading branch information
Showing
2 changed files
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/main/java/me/ShermansWorld/AlathraExtras/disabletrapdoorflipping/TrapdoorListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package me.ShermansWorld.AlathraExtras.disabletrapdoorflipping; | ||
|
||
import com.destroystokyo.paper.MaterialTags; | ||
import me.ShermansWorld.AlathraExtras.AlathraExtras; | ||
import org.bukkit.GameMode; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.Listener; | ||
import org.bukkit.event.block.Action; | ||
import org.bukkit.event.player.PlayerInteractEvent; | ||
|
||
/** | ||
* Listens for trapdoor interaction events | ||
*/ | ||
public class TrapdoorListener implements Listener { | ||
|
||
/** | ||
* Checks for player interactions with a trapdoor. | ||
* @param e the player interaction event | ||
*/ | ||
@EventHandler | ||
public void onInteract(PlayerInteractEvent e) { | ||
// Checks if the action is right click, and the right click is at a block. | ||
if(e.getAction() == Action.RIGHT_CLICK_BLOCK | ||
&& e.getClickedBlock() != null | ||
&& MaterialTags.TRAPDOORS.isTagged(e.getClickedBlock().getType()) | ||
&& e.getClickedBlock().getWorld().getName().equals("world") | ||
&& e.getPlayer().getGameMode() != GameMode.CREATIVE | ||
) // If so, cancel the interaction. | ||
{ | ||
e.setCancelled(true); | ||
} | ||
} | ||
} |