Skip to content

Commit

Permalink
Fix target blocks and entities not protected from fishing rods
Browse files Browse the repository at this point in the history
  • Loading branch information
cjburkey01 committed Aug 8, 2024
1 parent 35a441d commit f2edb49
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ public void unloadAllProfiles() {
mat.name().endsWith("_PRESSURE_PLATE")
|| mat.name().endsWith("_BUTTON"))
.forEach(redstone::add);
redstone.add(Material.TARGET);
blockAccessMapping.put("REDSTONE", redstone);

// Add door blocks
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
import java.util.*;
import java.util.function.Function;

@SuppressWarnings({"unused"})
@SuppressWarnings("unused")
public record WorldProfileEventHandler(ClaimChunk claimChunk) implements Listener {

// -- EVENTS -- //
Expand Down Expand Up @@ -75,6 +75,24 @@ public void onEntityDamage(EntityDamageByEntityEvent event) {
}
}

/** Event handler for when the player uses their fishing rod. */
@EventHandler
public void onPlayerFish(PlayerFishEvent event) {
if (event != null
&& !event.isCancelled()
&& event.getState() == PlayerFishEvent.State.CAUGHT_ENTITY) {
Entity caught = event.getCaught();
if (caught != null) {
// Check if the line has hit an entity, and check the perms.
onEntityEvent(
() -> event.setCancelled(true),
event.getPlayer(),
caught,
EntityAccess.EntityAccessType.DAMAGE);
}
}
}

/** Event handler for when an entity spawns. */
@EventHandler
public void onEntitySpawn(CreatureSpawnEvent event) {
Expand Down Expand Up @@ -391,7 +409,6 @@ public void onEntityDamagedByExplosion(EntityDamageEvent event) {
/* Explosion protection for blocks from block and entity explosions */

/** Event handler for when a block explodes. */
@SuppressWarnings("unused")
@EventHandler
public void onBlockExplode(BlockExplodeEvent event) {
if (event != null && !event.isCancelled()) {
Expand All @@ -400,7 +417,6 @@ public void onBlockExplode(BlockExplodeEvent event) {
}

/** Event handler for when an entity explodes. */
@SuppressWarnings("unused")
@EventHandler
public void onEntityExplode(EntityExplodeEvent event) {
if (event != null && !event.isCancelled()) {
Expand All @@ -409,7 +425,6 @@ public void onEntityExplode(EntityExplodeEvent event) {
}

/** Event handler for when a block spreads, like fire. */
@SuppressWarnings("unused")
@EventHandler
public void onFireSpread(BlockSpreadEvent event) {
if (event != null && !event.isCancelled() && event.getSource().getType() == Material.FIRE) {
Expand All @@ -424,7 +439,6 @@ public void onFireSpread(BlockSpreadEvent event) {
/**
* Event handler for when a liquid spreads, like water or lava, or when a dragon egg teleports.
*/
@SuppressWarnings("unused")
@EventHandler
public void onLiquidAndDragonEggSpread(BlockFromToEvent event) {
if (event != null && !event.isCancelled()) {
Expand Down Expand Up @@ -476,7 +490,6 @@ public void onLiquidAndDragonEggSpread(BlockFromToEvent event) {

/* Piston protections */

@SuppressWarnings("unused")
@EventHandler
public void onPistonExtend(BlockPistonExtendEvent event) {
if (event != null && !event.isCancelled()) {
Expand All @@ -488,7 +501,6 @@ public void onPistonExtend(BlockPistonExtendEvent event) {
}
}

@SuppressWarnings("unused")
@EventHandler
public void onPistonRetract(BlockPistonRetractEvent event) {
if (event != null && !event.isCancelled()) {
Expand Down

0 comments on commit f2edb49

Please sign in to comment.