Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -28,6 +28,7 @@
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.plot.flag.implementations.DisableBlockUpdateFlag;
import com.plotsquared.core.plot.flag.implementations.DisablePhysicsFlag;
import com.plotsquared.core.plot.flag.implementations.RedstoneFlag;
import com.plotsquared.core.plot.world.PlotAreaManager;
Expand All @@ -47,6 +48,7 @@
import org.bukkit.event.block.BlockRedstoneEvent;
import org.checkerframework.checker.nullness.qual.NonNull;

import java.util.Locale;
import java.util.Set;
import java.util.UUID;

Expand Down Expand Up @@ -152,6 +154,7 @@ public void onRedstoneEvent(BlockRedstoneEvent event) {
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onPhysicsEvent(BlockPhysicsEvent event) {
Block block = event.getBlock();
Block sourceBlock = event.getSourceBlock();
Location location = BukkitUtil.adapt(block.getLocation());
PlotArea area = location.getPlotArea();
if (area == null) {
Expand All @@ -167,6 +170,18 @@ public void onPhysicsEvent(BlockPhysicsEvent event) {
plot.debug("Prevented block physics and resent block change because disable-physics = true");
return;
}
if (plot.getFlag(DisableBlockUpdateFlag.class)) {
if (!event.getChangedType().hasGravity()) {
if (sourceBlock.getType().isAir() || block.getType().isAir()) {
return;
}
if (!sourceBlock.getType().name().toLowerCase(Locale.ROOT).contains("snow")
|| !block.getLocation().add(0, -1, 0).getBlock().getType().equals(Material.GRASS_BLOCK)) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still think this is a massively specific implementation. It should be an "all or nothing" which is why I question its inclusion; this might be how you want it, but it's not necessarily how others might want it to be implemented. This is why I suggest it might make better sense in a separate plugin where it is configurable

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For which practical creative construction use-case was this implemented? I would also say that “no block update” does not need any filter.

event.setCancelled(true);
plot.debug("Prevented block update because disable-block-update = true");
}
}
}
if (event.getChangedType() == Material.COMPARATOR) {
if (!plot.getFlag(RedstoneFlag.class)) {
event.setCancelled(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import com.plotsquared.core.plot.flag.implementations.DenyTeleportFlag;
import com.plotsquared.core.plot.flag.implementations.DescriptionFlag;
import com.plotsquared.core.plot.flag.implementations.DeviceInteractFlag;
import com.plotsquared.core.plot.flag.implementations.DisableBlockUpdateFlag;
import com.plotsquared.core.plot.flag.implementations.DisablePhysicsFlag;
import com.plotsquared.core.plot.flag.implementations.DoneFlag;
import com.plotsquared.core.plot.flag.implementations.DropProtectionFlag;
Expand Down Expand Up @@ -158,6 +159,7 @@ private GlobalFlagContainer() {
this.addFlag(DenyPortalTravelFlag.DENY_PORTAL_TRAVEL_FALSE);
this.addFlag(DeviceInteractFlag.DEVICE_INTERACT_FALSE);
this.addFlag(DisablePhysicsFlag.DISABLE_PHYSICS_FALSE);
this.addFlag(DisableBlockUpdateFlag.DISABLE_BLOCK_UPDATE_FLAG_FALSE);
this.addFlag(DropProtectionFlag.DROP_PROTECTION_FALSE);
this.addFlag(EditSignFlag.EDIT_SIGN_FALSE);
this.addFlag(EntityChangeBlockFlag.ENTITY_CHANGE_BLOCK_FALSE);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* PlotSquared, a land and world management plugin for Minecraft.
* Copyright (C) IntellectualSites <https://intellectualsites.com>
* Copyright (C) IntellectualSites team and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.core.plot.flag.implementations;

import com.plotsquared.core.configuration.caption.TranslatableCaption;
import com.plotsquared.core.plot.flag.types.BooleanFlag;
import org.checkerframework.checker.nullness.qual.NonNull;

public class DisableBlockUpdateFlag extends BooleanFlag<DisableBlockUpdateFlag> {

public static final DisableBlockUpdateFlag DISABLE_BLOCK_UPDATE_FLAG_TRUE = new DisableBlockUpdateFlag(true);
public static final DisableBlockUpdateFlag DISABLE_BLOCK_UPDATE_FLAG_FALSE = new DisableBlockUpdateFlag(false);

private DisableBlockUpdateFlag(boolean value) {
super(value, TranslatableCaption.of("flags.flag_description_disable_block_update"));
}

@Override
protected DisableBlockUpdateFlag flagOf(@NonNull Boolean value) {
return value ? DISABLE_BLOCK_UPDATE_FLAG_TRUE : DISABLE_BLOCK_UPDATE_FLAG_FALSE;
}
}
1 change: 1 addition & 0 deletions Core/src/main/resources/lang/messages_en.json
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,7 @@
"flags.flag_description_concrete_harden": "<gray>Set to `false` to disable concrete powder forming to concrete with water.</gray>",
"flags.flag_description_device_interact": "<gray>Set to `true` to allow devices to be interacted with in the plot.</gray>",
"flags.flag_description_disable_physics": "<gray>Set to `true` to disable block physics in the plot.</gray>",
"flags.flag_description_disable_block_update": "<gray>Set to `true` to disable block update in the plot.</gray>",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"flags.flag_description_disable_block_update": "<gray>Set to `true` to disable block update in the plot.</gray>",
"flags.flag_description_disable_block_update": "<gray>Set to `true` to disable block updates in the plot, e.g. breaking of flowers when the block below is removed.</gray>",

"flags.flag_description_drop_protection": "<gray>Set to `true` to prevent dropped items from being picked up by non-members of the plot.</gray>",
"flags.flag_description_edit_sign": "<gray>Set to `true` to allow editing signs in the plot.</gray>",
"flags.flag_description_feed": "<gray>Specify an interval in seconds and an optional amount by which the players will be fed (amount is 1 by default).</gray>",
Expand Down