mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-25 12:25:46 +01:00
Add Plot flag for projectiles (#3581)
* feature: add flag for projectiles * build: add License to ProjectilesFlag.java Co-authored-by: Alexander Brandes <mc.cache@web.de>
This commit is contained in:
parent
d71c62771e
commit
f49ddb819d
@ -44,6 +44,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.DoneFlag;
|
||||
import com.plotsquared.core.plot.flag.implementations.ProjectilesFlag;
|
||||
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||
import com.plotsquared.core.util.Permissions;
|
||||
import net.kyori.adventure.text.minimessage.Template;
|
||||
@ -352,13 +353,15 @@ public class PaperListener implements Listener {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
} else if (!plot.isAdded(pp.getUUID())) {
|
||||
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_PROJECTILE_OTHER)) {
|
||||
pp.sendMessage(
|
||||
TranslatableCaption.of("permission.no_permission_event"),
|
||||
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_PROJECTILE_OTHER))
|
||||
);
|
||||
entity.remove();
|
||||
event.setCancelled(true);
|
||||
if (!plot.getFlag(ProjectilesFlag.class)) {
|
||||
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_PROJECTILE_OTHER)) {
|
||||
pp.sendMessage(
|
||||
TranslatableCaption.of("permission.no_permission_event"),
|
||||
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_PROJECTILE_OTHER))
|
||||
);
|
||||
entity.remove();
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -35,6 +35,7 @@ import com.plotsquared.core.player.PlotPlayer;
|
||||
import com.plotsquared.core.plot.Plot;
|
||||
import com.plotsquared.core.plot.PlotArea;
|
||||
import com.plotsquared.core.plot.PlotHandler;
|
||||
import com.plotsquared.core.plot.flag.implementations.ProjectilesFlag;
|
||||
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||
import com.plotsquared.core.util.Permissions;
|
||||
import net.kyori.adventure.text.minimessage.Template;
|
||||
@ -128,13 +129,15 @@ public class ProjectileEventListener implements Listener {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
} else if (!plot.isAdded(pp.getUUID())) {
|
||||
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_PROJECTILE_OTHER)) {
|
||||
pp.sendMessage(
|
||||
TranslatableCaption.of("permission.no_permission_event"),
|
||||
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_PROJECTILE_OTHER))
|
||||
);
|
||||
entity.remove();
|
||||
event.setCancelled(true);
|
||||
if (!plot.getFlag(ProjectilesFlag.class)) {
|
||||
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_PROJECTILE_OTHER)) {
|
||||
pp.sendMessage(
|
||||
TranslatableCaption.of("permission.no_permission_event"),
|
||||
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_PROJECTILE_OTHER))
|
||||
);
|
||||
entity.remove();
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -162,7 +165,7 @@ public class ProjectileEventListener implements Listener {
|
||||
return;
|
||||
}
|
||||
if (plot.isAdded(pp.getUUID()) || Permissions
|
||||
.hasPermission(pp, Permission.PERMISSION_ADMIN_PROJECTILE_OTHER)) {
|
||||
.hasPermission(pp, Permission.PERMISSION_ADMIN_PROJECTILE_OTHER) || plot.getFlag(ProjectilesFlag.class)) {
|
||||
return;
|
||||
}
|
||||
entity.remove();
|
||||
|
@ -93,6 +93,7 @@ import com.plotsquared.core.plot.flag.implementations.PlayerInteractFlag;
|
||||
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.ProjectilesFlag;
|
||||
import com.plotsquared.core.plot.flag.implementations.PveFlag;
|
||||
import com.plotsquared.core.plot.flag.implementations.PvpFlag;
|
||||
import com.plotsquared.core.plot.flag.implementations.RedstoneFlag;
|
||||
@ -198,6 +199,7 @@ public final class GlobalFlagContainer extends FlagContainer {
|
||||
this.addFlag(VehicleUseFlag.VEHICLE_USE_FALSE);
|
||||
this.addFlag(VillagerInteractFlag.VILLAGER_INTERACT_FALSE);
|
||||
this.addFlag(VineGrowFlag.VINE_GROW_TRUE);
|
||||
this.addFlag(ProjectilesFlag.PROJECTILES_FALSE);
|
||||
|
||||
// Double flags
|
||||
this.addFlag(PriceFlag.PRICE_NOT_BUYABLE);
|
||||
|
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* _____ _ _ _____ _
|
||||
* | __ \| | | | / ____| | |
|
||||
* | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| |
|
||||
* | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
|
||||
* | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| |
|
||||
* |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_|
|
||||
* | |
|
||||
* |_|
|
||||
* PlotSquared plot management system for Minecraft
|
||||
* Copyright (C) 2014 - 2022 IntellectualSites
|
||||
*
|
||||
* 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 ProjectilesFlag extends BooleanFlag<ProjectilesFlag> {
|
||||
|
||||
public static final ProjectilesFlag PROJECTILES_TRUE = new ProjectilesFlag(true);
|
||||
public static final ProjectilesFlag PROJECTILES_FALSE = new ProjectilesFlag(false);
|
||||
|
||||
private ProjectilesFlag(boolean value){
|
||||
super(value, TranslatableCaption.of("flags.flag_description_projectiles"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ProjectilesFlag flagOf(@NonNull final Boolean value) {
|
||||
return value ? PROJECTILES_TRUE : PROJECTILES_FALSE;
|
||||
}
|
||||
|
||||
}
|
@ -613,6 +613,7 @@
|
||||
"flags.flag_description_lectern_read_book": "<gray>Prevent players taking books from lecterns.</gray>",
|
||||
"flags.flag_description_prevent_creative_copy": "<gray>Prevents people from copying item NBT data in the plot unless they're added as members.</gray>",
|
||||
"flags.flag_description_leaf_decay": "<gray>Set to `false` to prevent leaves from decaying.",
|
||||
"flags.flag_description_projectiles": "<gray>Prevents guests from shooting projectiles on the plot when set to false.</gray>",
|
||||
"flags.flag_error_boolean": "Flag value must be a boolean (true | false).",
|
||||
"flags.flag_error_enum": "Must be one of: <list>",
|
||||
"flags.flag_error_integer": "Flag value must be a whole positive number.",
|
||||
|
Loading…
Reference in New Issue
Block a user