mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-23 21:56:45 +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.Plot;
|
||||||
import com.plotsquared.core.plot.PlotArea;
|
import com.plotsquared.core.plot.PlotArea;
|
||||||
import com.plotsquared.core.plot.flag.implementations.DoneFlag;
|
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.plot.world.PlotAreaManager;
|
||||||
import com.plotsquared.core.util.Permissions;
|
import com.plotsquared.core.util.Permissions;
|
||||||
import net.kyori.adventure.text.minimessage.Template;
|
import net.kyori.adventure.text.minimessage.Template;
|
||||||
@ -352,6 +353,7 @@ public class PaperListener implements Listener {
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
} else if (!plot.isAdded(pp.getUUID())) {
|
} else if (!plot.isAdded(pp.getUUID())) {
|
||||||
|
if (!plot.getFlag(ProjectilesFlag.class)) {
|
||||||
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_PROJECTILE_OTHER)) {
|
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_PROJECTILE_OTHER)) {
|
||||||
pp.sendMessage(
|
pp.sendMessage(
|
||||||
TranslatableCaption.of("permission.no_permission_event"),
|
TranslatableCaption.of("permission.no_permission_event"),
|
||||||
@ -362,6 +364,7 @@ public class PaperListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onAsyncTabCompletion(final AsyncTabCompleteEvent event) {
|
public void onAsyncTabCompletion(final AsyncTabCompleteEvent event) {
|
||||||
|
@ -35,6 +35,7 @@ import com.plotsquared.core.player.PlotPlayer;
|
|||||||
import com.plotsquared.core.plot.Plot;
|
import com.plotsquared.core.plot.Plot;
|
||||||
import com.plotsquared.core.plot.PlotArea;
|
import com.plotsquared.core.plot.PlotArea;
|
||||||
import com.plotsquared.core.plot.PlotHandler;
|
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.plot.world.PlotAreaManager;
|
||||||
import com.plotsquared.core.util.Permissions;
|
import com.plotsquared.core.util.Permissions;
|
||||||
import net.kyori.adventure.text.minimessage.Template;
|
import net.kyori.adventure.text.minimessage.Template;
|
||||||
@ -128,6 +129,7 @@ public class ProjectileEventListener implements Listener {
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
} else if (!plot.isAdded(pp.getUUID())) {
|
} else if (!plot.isAdded(pp.getUUID())) {
|
||||||
|
if (!plot.getFlag(ProjectilesFlag.class)) {
|
||||||
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_PROJECTILE_OTHER)) {
|
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_PROJECTILE_OTHER)) {
|
||||||
pp.sendMessage(
|
pp.sendMessage(
|
||||||
TranslatableCaption.of("permission.no_permission_event"),
|
TranslatableCaption.of("permission.no_permission_event"),
|
||||||
@ -138,6 +140,7 @@ public class ProjectileEventListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onProjectileHit(ProjectileHitEvent event) {
|
public void onProjectileHit(ProjectileHitEvent event) {
|
||||||
@ -162,7 +165,7 @@ public class ProjectileEventListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (plot.isAdded(pp.getUUID()) || Permissions
|
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;
|
return;
|
||||||
}
|
}
|
||||||
entity.remove();
|
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.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.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;
|
||||||
import com.plotsquared.core.plot.flag.implementations.RedstoneFlag;
|
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(VehicleUseFlag.VEHICLE_USE_FALSE);
|
||||||
this.addFlag(VillagerInteractFlag.VILLAGER_INTERACT_FALSE);
|
this.addFlag(VillagerInteractFlag.VILLAGER_INTERACT_FALSE);
|
||||||
this.addFlag(VineGrowFlag.VINE_GROW_TRUE);
|
this.addFlag(VineGrowFlag.VINE_GROW_TRUE);
|
||||||
|
this.addFlag(ProjectilesFlag.PROJECTILES_FALSE);
|
||||||
|
|
||||||
// Double flags
|
// Double flags
|
||||||
this.addFlag(PriceFlag.PRICE_NOT_BUYABLE);
|
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_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_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_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_boolean": "Flag value must be a boolean (true | false).",
|
||||||
"flags.flag_error_enum": "Must be one of: <list>",
|
"flags.flag_error_enum": "Must be one of: <list>",
|
||||||
"flags.flag_error_integer": "Flag value must be a whole positive number.",
|
"flags.flag_error_integer": "Flag value must be a whole positive number.",
|
||||||
|
Loading…
Reference in New Issue
Block a user