mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-21 11:45:19 +01:00
Introduce edit-sign
flag (#4236)
This commit is contained in:
parent
cdb44d4884
commit
31ae62b62c
@ -37,6 +37,7 @@ import com.plotsquared.bukkit.listener.EntityEventListener;
|
||||
import com.plotsquared.bukkit.listener.EntitySpawnListener;
|
||||
import com.plotsquared.bukkit.listener.PaperListener;
|
||||
import com.plotsquared.bukkit.listener.PlayerEventListener;
|
||||
import com.plotsquared.bukkit.listener.PlayerEventListener1201;
|
||||
import com.plotsquared.bukkit.listener.ProjectileEventListener;
|
||||
import com.plotsquared.bukkit.listener.ServerListener;
|
||||
import com.plotsquared.bukkit.listener.SingleWorldListener;
|
||||
@ -359,6 +360,9 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
|
||||
|
||||
if (Settings.Enabled_Components.EVENTS) {
|
||||
getServer().getPluginManager().registerEvents(injector().getInstance(PlayerEventListener.class), this);
|
||||
if ((serverVersion()[1] == 20 && serverVersion()[2] >= 1) || serverVersion()[1] > 20) {
|
||||
getServer().getPluginManager().registerEvents(injector().getInstance(PlayerEventListener1201.class), this);
|
||||
}
|
||||
getServer().getPluginManager().registerEvents(injector().getInstance(BlockEventListener.class), this);
|
||||
if (serverVersion()[1] >= 17) {
|
||||
getServer().getPluginManager().registerEvents(injector().getInstance(BlockEventListener117.class), this);
|
||||
|
@ -0,0 +1,63 @@
|
||||
/*
|
||||
* 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.bukkit.listener;
|
||||
|
||||
import com.plotsquared.bukkit.util.BukkitUtil;
|
||||
import com.plotsquared.core.location.Location;
|
||||
import com.plotsquared.core.plot.Plot;
|
||||
import com.plotsquared.core.plot.PlotArea;
|
||||
import com.plotsquared.core.plot.flag.implementations.EditSignFlag;
|
||||
import com.plotsquared.core.util.PlotFlagUtil;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerSignOpenEvent;
|
||||
|
||||
/**
|
||||
* For events since 1.20.1
|
||||
* @since TODO
|
||||
*/
|
||||
public class PlayerEventListener1201 implements Listener {
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
@SuppressWarnings({"removal", "UnstableApiUsage"}) // thanks Paper, thanks Spigot
|
||||
public void onPlayerSignOpenEvent(PlayerSignOpenEvent event) {
|
||||
Sign sign = event.getSign();
|
||||
Location location = BukkitUtil.adapt(sign.getLocation());
|
||||
PlotArea area = location.getPlotArea();
|
||||
if (area == null) {
|
||||
return;
|
||||
}
|
||||
Plot plot = location.getOwnedPlot();
|
||||
if (plot == null) {
|
||||
if (PlotFlagUtil.isAreaRoadFlagsAndFlagEquals(area, EditSignFlag.class, false)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (plot.isAdded(event.getPlayer().getUniqueId())) {
|
||||
return; // allow for added players
|
||||
}
|
||||
if (!plot.getFlag(EditSignFlag.class)) {
|
||||
plot.debug(event.getPlayer().getName() + " could not edit the sign because of edit-sign = false");
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -42,6 +42,7 @@ import com.plotsquared.core.plot.flag.implementations.DeviceInteractFlag;
|
||||
import com.plotsquared.core.plot.flag.implementations.DisablePhysicsFlag;
|
||||
import com.plotsquared.core.plot.flag.implementations.DoneFlag;
|
||||
import com.plotsquared.core.plot.flag.implementations.DropProtectionFlag;
|
||||
import com.plotsquared.core.plot.flag.implementations.EditSignFlag;
|
||||
import com.plotsquared.core.plot.flag.implementations.EntityCapFlag;
|
||||
import com.plotsquared.core.plot.flag.implementations.EntityChangeBlockFlag;
|
||||
import com.plotsquared.core.plot.flag.implementations.ExplosionFlag;
|
||||
@ -153,6 +154,7 @@ public final class GlobalFlagContainer extends FlagContainer {
|
||||
this.addFlag(DeviceInteractFlag.DEVICE_INTERACT_FALSE);
|
||||
this.addFlag(DisablePhysicsFlag.DISABLE_PHYSICS_FALSE);
|
||||
this.addFlag(DropProtectionFlag.DROP_PROTECTION_FALSE);
|
||||
this.addFlag(EditSignFlag.EDIT_SIGN_FALSE);
|
||||
this.addFlag(EntityChangeBlockFlag.ENTITY_CHANGE_BLOCK_FALSE);
|
||||
this.addFlag(ExplosionFlag.EXPLOSION_FALSE);
|
||||
this.addFlag(ForcefieldFlag.FORCEFIELD_FALSE);
|
||||
|
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* @since TODO
|
||||
*/
|
||||
public class EditSignFlag extends BooleanFlag<EditSignFlag> {
|
||||
public static final EditSignFlag EDIT_SIGN_TRUE = new EditSignFlag(true);
|
||||
public static final EditSignFlag EDIT_SIGN_FALSE = new EditSignFlag(false);
|
||||
|
||||
private EditSignFlag(final boolean value) {
|
||||
super(value, TranslatableCaption.of("flags.flag_description_edit_sign"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected EditSignFlag flagOf(@NonNull final Boolean value) {
|
||||
return value ? EDIT_SIGN_TRUE : EDIT_SIGN_FALSE;
|
||||
}
|
||||
|
||||
}
|
@ -63,6 +63,7 @@ import com.plotsquared.core.plot.PlotId;
|
||||
import com.plotsquared.core.plot.Rating;
|
||||
import com.plotsquared.core.plot.flag.PlotFlag;
|
||||
import com.plotsquared.core.plot.flag.implementations.DeviceInteractFlag;
|
||||
import com.plotsquared.core.plot.flag.implementations.EditSignFlag;
|
||||
import com.plotsquared.core.plot.flag.implementations.MiscPlaceFlag;
|
||||
import com.plotsquared.core.plot.flag.implementations.MobPlaceFlag;
|
||||
import com.plotsquared.core.plot.flag.implementations.PlaceFlag;
|
||||
@ -74,6 +75,7 @@ import com.plotsquared.core.util.task.TaskManager;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.entity.Entity;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.world.block.BlockCategories;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import net.kyori.adventure.text.Component;
|
||||
@ -392,6 +394,12 @@ public class EventDispatcher {
|
||||
if (player.hasPermission(Permission.PERMISSION_ADMIN_INTERACT_OTHER.toString(), false)) {
|
||||
return true;
|
||||
}
|
||||
// we check for the EditSignFlag in the PlayerSignOpenEvent again, but we must not cancel the interact event
|
||||
// or send a message if the flag is true
|
||||
if (BlockCategories.ALL_SIGNS != null && BlockCategories.ALL_SIGNS.contains(blockType)
|
||||
&& plot.getFlag(EditSignFlag.class)) {
|
||||
return true;
|
||||
}
|
||||
if (notifyPerms) {
|
||||
player.sendMessage(
|
||||
TranslatableCaption.of("commandconfig.flag_tutorial_usage"),
|
||||
|
@ -555,6 +555,7 @@
|
||||
"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_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>",
|
||||
"flags.flag_description_forcefield": "<gray>Set to `true` to enable member forcefield in the plot.</gray>",
|
||||
"flags.flag_description_grass_grow": "<gray>Set to `false` to prevent grass from growing within the plot.</gray>",
|
||||
|
@ -1,8 +1,8 @@
|
||||
import com.diffplug.gradle.spotless.SpotlessPlugin
|
||||
import com.github.jengelman.gradle.plugins.shadow.ShadowPlugin
|
||||
import groovy.json.JsonSlurper
|
||||
import java.net.URI
|
||||
import xyz.jpenilla.runpaper.task.RunServer
|
||||
import java.net.URI
|
||||
|
||||
plugins {
|
||||
java
|
||||
|
Loading…
Reference in New Issue
Block a user