feat: add projectile-change-block flag (#4185)

- closes #4081
This commit is contained in:
Jordan 2023-12-12 13:53:10 +00:00 committed by GitHub
parent 7931c0864e
commit 4a45729c9e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 45 additions and 2 deletions

View File

@ -35,6 +35,7 @@ import com.plotsquared.core.plot.flag.implementations.DisablePhysicsFlag;
import com.plotsquared.core.plot.flag.implementations.EntityChangeBlockFlag; import com.plotsquared.core.plot.flag.implementations.EntityChangeBlockFlag;
import com.plotsquared.core.plot.flag.implementations.ExplosionFlag; import com.plotsquared.core.plot.flag.implementations.ExplosionFlag;
import com.plotsquared.core.plot.flag.implementations.InvincibleFlag; import com.plotsquared.core.plot.flag.implementations.InvincibleFlag;
import com.plotsquared.core.plot.flag.implementations.ProjectileChangeBlockFlag;
import com.plotsquared.core.plot.world.PlotAreaManager; import com.plotsquared.core.plot.world.PlotAreaManager;
import com.plotsquared.core.util.EventDispatcher; import com.plotsquared.core.util.EventDispatcher;
import com.plotsquared.core.util.PlotFlagUtil; import com.plotsquared.core.util.PlotFlagUtil;
@ -358,13 +359,13 @@ public class EntityEventListener implements Listener {
if (shooter instanceof Player) { if (shooter instanceof Player) {
PlotPlayer<?> pp = BukkitUtil.adapt((Player) shooter); PlotPlayer<?> pp = BukkitUtil.adapt((Player) shooter);
if (plot == null) { if (plot == null) {
if (!pp.hasPermission(Permission.PERMISSION_ADMIN_PROJECTILE_UNOWNED)) { if (area.isRoadFlags() && !area.getRoadFlag(ProjectileChangeBlockFlag.class) && !pp.hasPermission(Permission.PERMISSION_ADMIN_PROJECTILE_UNOWNED)) {
entity.remove(); entity.remove();
event.setCancelled(true); event.setCancelled(true);
} }
return; return;
} }
if (plot.isAdded(pp.getUUID()) || pp.hasPermission(Permission.PERMISSION_ADMIN_PROJECTILE_OTHER)) { if (plot.isAdded(pp.getUUID()) || plot.getFlag(ProjectileChangeBlockFlag.class) || pp.hasPermission(Permission.PERMISSION_ADMIN_PROJECTILE_OTHER)) {
return; return;
} }
entity.remove(); entity.remove();

View File

@ -89,6 +89,7 @@ import com.plotsquared.core.plot.flag.implementations.PlayerInteractFlag;
import com.plotsquared.core.plot.flag.implementations.PlotTitleFlag; import com.plotsquared.core.plot.flag.implementations.PlotTitleFlag;
import com.plotsquared.core.plot.flag.implementations.PreventCreativeCopyFlag; import com.plotsquared.core.plot.flag.implementations.PreventCreativeCopyFlag;
import com.plotsquared.core.plot.flag.implementations.PriceFlag; import com.plotsquared.core.plot.flag.implementations.PriceFlag;
import com.plotsquared.core.plot.flag.implementations.ProjectileChangeBlockFlag;
import com.plotsquared.core.plot.flag.implementations.ProjectilesFlag; import com.plotsquared.core.plot.flag.implementations.ProjectilesFlag;
import com.plotsquared.core.plot.flag.implementations.PveFlag; import com.plotsquared.core.plot.flag.implementations.PveFlag;
import com.plotsquared.core.plot.flag.implementations.PvpFlag; import com.plotsquared.core.plot.flag.implementations.PvpFlag;
@ -185,6 +186,7 @@ public final class GlobalFlagContainer extends FlagContainer {
this.addFlag(NoWorldeditFlag.NO_WORLDEDIT_FALSE); this.addFlag(NoWorldeditFlag.NO_WORLDEDIT_FALSE);
this.addFlag(PlayerInteractFlag.PLAYER_INTERACT_FALSE); this.addFlag(PlayerInteractFlag.PLAYER_INTERACT_FALSE);
this.addFlag(PreventCreativeCopyFlag.PREVENT_CREATIVE_COPY_FALSE); this.addFlag(PreventCreativeCopyFlag.PREVENT_CREATIVE_COPY_FALSE);
this.addFlag(ProjectileChangeBlockFlag.PROJECTILE_CHANGE_BLOCK_FALSE);
this.addFlag(PveFlag.PVE_FALSE); this.addFlag(PveFlag.PVE_FALSE);
this.addFlag(PvpFlag.PVP_FALSE); this.addFlag(PvpFlag.PVP_FALSE);
this.addFlag(RedstoneFlag.REDSTONE_TRUE); this.addFlag(RedstoneFlag.REDSTONE_TRUE);

View File

@ -0,0 +1,39 @@
/*
* 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 ProjectileChangeBlockFlag extends BooleanFlag<ProjectileChangeBlockFlag> {
public static final ProjectileChangeBlockFlag PROJECTILE_CHANGE_BLOCK_TRUE = new ProjectileChangeBlockFlag(true);
public static final ProjectileChangeBlockFlag PROJECTILE_CHANGE_BLOCK_FALSE = new ProjectileChangeBlockFlag(false);
private ProjectileChangeBlockFlag(boolean value) {
super(value, TranslatableCaption.of("flags.flag_description_projectile_change_block"));
}
@Override
protected ProjectileChangeBlockFlag flagOf(@NonNull Boolean value) {
return value ? PROJECTILE_CHANGE_BLOCK_TRUE : PROJECTILE_CHANGE_BLOCK_FALSE;
}
}

View File

@ -589,6 +589,7 @@
"flags.flag_description_place": "<gray>Define a list of materials players should be able to place in the plot.</gray>", "flags.flag_description_place": "<gray>Define a list of materials players should be able to place in the plot.</gray>",
"flags.flag_description_player_interact": "<gray>Set to `true` to allow guests to interact with players in the plot.</gray>", "flags.flag_description_player_interact": "<gray>Set to `true` to allow guests to interact with players in the plot.</gray>",
"flags.flag_description_price": "<gray>Set a price for a plot. Must be a positive decimal number.</gray>", "flags.flag_description_price": "<gray>Set a price for a plot. Must be a positive decimal number.</gray>",
"flags.flag_description_projectile_change_block": "<gray>Set to `true` to allow projectiles to change blocks (tnt, etc.) on the plot.</gray>",
"flags.flag_description_pve": "<gray>Set to `true` to enable PVE inside the plot.</gray>", "flags.flag_description_pve": "<gray>Set to `true` to enable PVE inside the plot.</gray>",
"flags.flag_description_pvp": "<gray>Set to `true` to enable PVP inside the plot.</gray>", "flags.flag_description_pvp": "<gray>Set to `true` to enable PVP inside the plot.</gray>",
"flags.flag_description_redstone": "<gray>Set to `false` to disable redstone in the plot.</gray>", "flags.flag_description_redstone": "<gray>Set to `false` to disable redstone in the plot.</gray>",