Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make respawn anchors respect the deny bed use option #5942

Merged
merged 2 commits into from
Jun 6, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import org.bukkit.World.Environment;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.data.type.RespawnAnchor;
import org.bukkit.block.data.type.Sign;
import org.bukkit.block.data.type.WallSign;
import org.bukkit.entity.Entity;
Expand Down Expand Up @@ -413,9 +414,9 @@ public void onPlayerBlowsUpBedOrRespawnAnchor(PlayerInteractEvent event) {
/*
* Catches respawn anchors blowing up and allows us to track their explosions.
*/
if (block.getType().name().equals("RESPAWN_ANCHOR")) {
org.bukkit.block.data.type.RespawnAnchor anchor = ((org.bukkit.block.data.type.RespawnAnchor) block.getBlockData());
if (anchor.getCharges() == 4)
if (block.getType() == Material.RESPAWN_ANCHOR && event.getAction() == Action.RIGHT_CLICK_BLOCK && !block.getWorld().isRespawnAnchorWorks()) {
RespawnAnchor anchor = ((RespawnAnchor) block.getBlockData());
if (anchor.getCharges() > 0)
BukkitTools.getPluginManager().callEvent(new BedExplodeEvent(player, blockLoc, null, block.getType()));
return;
}
Expand All @@ -440,10 +441,10 @@ public void onPlayerBlowsUpBedOrRespawnAnchor(PlayerInteractEvent event) {
}

/*
* Prevents setting the spawn point of the player using beds,
* Prevents setting the spawn point of the player using beds or respawn anchors,
* except in allowed plots (personally-owned and Inns)
*/
if (Tag.BEDS.isTagged(block.getType()) && event.getAction() == Action.RIGHT_CLICK_BLOCK) {
if (event.getAction() == Action.RIGHT_CLICK_BLOCK && (Tag.BEDS.isTagged(block.getType()) || (block.getWorld().isRespawnAnchorWorks() && block.getBlockData() instanceof RespawnAnchor anchor && anchor.getCharges() > 0 && (event.getItem() == null || (event.getItem().getType() != Material.GLOWSTONE || anchor.getCharges() >= anchor.getMaximumCharges()))))) {
if (!TownySettings.getBedUse())
return;

Expand Down