Skip to content

Commit 73cb09c

Browse files
authored
Merge pull request #2684 from stuffyerface/develop
Fix issues relating to #2422
2 parents 6dae524 + aeaa279 commit 73cb09c

File tree

4 files changed

+12
-11
lines changed

4 files changed

+12
-11
lines changed

src/main/java/world/bentobox/bentobox/listeners/flags/protection/BlockInteractionListener.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ private void checkClickedBlock(Event e, Player player, Block block)
105105
case BEEHIVE, BEE_NEST -> this.checkIsland(e, player, loc, Flags.HIVE);
106106
case BARREL -> this.checkIsland(e, player, loc, Flags.BARREL);
107107
case CANDLE -> this.checkIsland(e, player, loc, Flags.CANDLES);
108+
case CRAFTER -> this.checkIsland(e, player, loc, Flags.CRAFTER);
108109
case CHEST, CHEST_MINECART -> this.checkIsland(e, player, loc, Flags.CHEST);
109110
case TRAPPED_CHEST -> this.checkIsland(e, player, loc, Flags.TRAPPED_CHEST);
110111
case FLOWER_POT -> this.checkIsland(e, player, loc, Flags.FLOWER_POT);

src/main/java/world/bentobox/bentobox/listeners/flags/protection/BreakBlocksListener.java

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import org.bukkit.Location;
44
import org.bukkit.Material;
55
import org.bukkit.Tag;
6-
import org.bukkit.block.data.BlockData;
76
import org.bukkit.block.data.type.CaveVinesPlant;
87
import org.bukkit.entity.ArmorStand;
98
import org.bukkit.entity.EnderCrystal;
@@ -195,25 +194,21 @@ private boolean notAllowed(EntityDamageByEntityEvent e, Player player, Location
195194
*/
196195
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
197196
public void onProjectileHitBreakBlock(ProjectileHitEvent e) {
198-
// We want to make sure this is an actual projectile (arrow or trident)
199-
if (!(e.getEntity() instanceof Projectile)) {
197+
if (e.getHitBlock() == null) {
200198
return;
201199
}
202200

203-
// We want to make sure it hit a CHORUS_FLOWER
204-
if (e.getHitBlock() == null || !e.getHitBlock().getType().equals(Material.CHORUS_FLOWER)) {
201+
// Check if the hit block is a Chorus Flower or a Decorated Pot
202+
if(!(e.getHitBlock().getType().equals(Material.CHORUS_FLOWER) ||
203+
e.getHitBlock().getType().equals(Material.DECORATED_POT))) {
205204
return;
206205
}
207206

208207
// Find out who fired the arrow
209208
if (e.getEntity().getShooter() instanceof Player s &&
210209
!checkIsland(e, s, e.getHitBlock().getLocation(), Flags.BREAK_BLOCKS)) {
211-
final BlockData data = e.getHitBlock().getBlockData();
212-
// We seemingly can't prevent the block from being destroyed
213-
// So we need to put it back with a slight delay (yup, this is hacky - it makes the block flicker sometimes)
214-
e.getHitBlock().setType(Material.AIR); // prevents the block from dropping a chorus flower
215-
getPlugin().getServer().getScheduler().runTask(getPlugin(), () -> e.getHitBlock().setBlockData(data, true));
216-
// Sorry, this might also cause some ghost blocks!
210+
211+
e.setCancelled(true); // Prevents the block from being destroyed
217212
}
218213
}
219214
}

src/main/java/world/bentobox/bentobox/lists/Flags.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ private Flags() {}
126126
public static final Flag FLOWER_POT = new Flag.Builder("FLOWER_POT", Material.FLOWER_POT).mode(Flag.Mode.ADVANCED).build();
127127
public static final Flag SHULKER_BOX = new Flag.Builder("SHULKER_BOX", Material.SHULKER_BOX).mode(Flag.Mode.ADVANCED).build();
128128
public static final Flag TRAPPED_CHEST = new Flag.Builder("TRAPPED_CHEST", Material.TRAPPED_CHEST).mode(Flag.Mode.ADVANCED).build();
129+
public static final Flag CRAFTER = new Flag.Builder("CRAFTER", Material.CRAFTER).mode(Flag.Mode.ADVANCED).build();
129130
// END CONTAINER split
130131
public static final Flag DISPENSER = new Flag.Builder("DISPENSER", Material.DISPENSER).mode(Flag.Mode.ADVANCED).build();
131132
public static final Flag DROPPER = new Flag.Builder("DROPPER", Material.DROPPER).mode(Flag.Mode.ADVANCED).build();

src/main/resources/locales/en-US.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,6 +1055,10 @@ protection:
10551055
name: Barrels
10561056
description: Toggle barrel interaction
10571057
hint: Barrel access disabled
1058+
CRAFTER:
1059+
name: Crafter
1060+
description: Toggle use
1061+
hint: Crafter access disabled
10581062
BLOCK_EXPLODE_DAMAGE:
10591063
description: |-
10601064
&a Allow Bed & Respawn Anchors

0 commit comments

Comments
 (0)