Skip to content

Commit

Permalink
feat: add projectile-change-block flag (#4185)
Browse files Browse the repository at this point in the history
 - closes #4081
  • Loading branch information
dordsor21 authored Dec 12, 2023
1 parent 7931c08 commit 4a45729
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import com.plotsquared.core.plot.flag.implementations.EntityChangeBlockFlag;
import com.plotsquared.core.plot.flag.implementations.ExplosionFlag;
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.util.EventDispatcher;
import com.plotsquared.core.util.PlotFlagUtil;
Expand Down Expand Up @@ -358,13 +359,13 @@ public void onPeskyMobsChangeTheWorldLikeWTFEvent(EntityChangeBlockEvent event)
if (shooter instanceof Player) {
PlotPlayer<?> pp = BukkitUtil.adapt((Player) shooter);
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();
event.setCancelled(true);
}
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;
}
entity.remove();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
import com.plotsquared.core.plot.flag.implementations.PlotTitleFlag;
import com.plotsquared.core.plot.flag.implementations.PreventCreativeCopyFlag;
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.PveFlag;
import com.plotsquared.core.plot.flag.implementations.PvpFlag;
Expand Down Expand Up @@ -185,6 +186,7 @@ private GlobalFlagContainer() {
this.addFlag(NoWorldeditFlag.NO_WORLDEDIT_FALSE);
this.addFlag(PlayerInteractFlag.PLAYER_INTERACT_FALSE);
this.addFlag(PreventCreativeCopyFlag.PREVENT_CREATIVE_COPY_FALSE);
this.addFlag(ProjectileChangeBlockFlag.PROJECTILE_CHANGE_BLOCK_FALSE);
this.addFlag(PveFlag.PVE_FALSE);
this.addFlag(PvpFlag.PVP_FALSE);
this.addFlag(RedstoneFlag.REDSTONE_TRUE);
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}

}
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 @@ -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_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_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_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>",
Expand Down

0 comments on commit 4a45729

Please sign in to comment.