|
50 | 50 | import com.plotsquared.core.plot.flag.implementations.DenyTeleportFlag;
|
51 | 51 | import com.plotsquared.core.plot.flag.implementations.DoneFlag;
|
52 | 52 | import com.plotsquared.core.plot.flag.implementations.DropProtectionFlag;
|
| 53 | +import com.plotsquared.core.plot.flag.implementations.EditSignFlag; |
53 | 54 | import com.plotsquared.core.plot.flag.implementations.HangingBreakFlag;
|
54 | 55 | import com.plotsquared.core.plot.flag.implementations.HangingPlaceFlag;
|
55 | 56 | import com.plotsquared.core.plot.flag.implementations.HostileInteractFlag;
|
|
87 | 88 | import org.bukkit.block.Block;
|
88 | 89 | import org.bukkit.block.BlockFace;
|
89 | 90 | import org.bukkit.block.BlockState;
|
| 91 | +import org.bukkit.block.Sign; |
90 | 92 | import org.bukkit.block.data.Waterlogged;
|
91 | 93 | import org.bukkit.command.PluginCommand;
|
92 | 94 | import org.bukkit.entity.ArmorStand;
|
@@ -175,6 +177,33 @@ public class PlayerEventListener implements Listener {
|
175 | 177 | Material.WRITABLE_BOOK,
|
176 | 178 | Material.WRITTEN_BOOK
|
177 | 179 | );
|
| 180 | + private static final Set<String> DYES; |
| 181 | + static { |
| 182 | + Set<String> mutableDyes = new HashSet<>(Set.of( |
| 183 | + "WHITE_DYE", |
| 184 | + "LIGHT_GRAY_DYE", |
| 185 | + "GRAY_DYE", |
| 186 | + "BLACK_DYE", |
| 187 | + "BROWN_DYE", |
| 188 | + "RED_DYE", |
| 189 | + "ORANGE_DYE", |
| 190 | + "YELLOW_DYE", |
| 191 | + "LIME_DYE", |
| 192 | + "GREEN_DYE", |
| 193 | + "CYAN_DYE", |
| 194 | + "LIGHT_BLUE_DYE", |
| 195 | + "BLUE_DYE", |
| 196 | + "PURPLE_DYE", |
| 197 | + "MAGENTA_DYE", |
| 198 | + "PINK_DYE", |
| 199 | + "GLOW_INK_SAC" |
| 200 | + )); |
| 201 | + int[] version = PlotSquared.platform().serverVersion(); |
| 202 | + if (version[1] >= 20 && version[2] >= 1) { |
| 203 | + mutableDyes.add("HONEYCOMB"); |
| 204 | + } |
| 205 | + DYES = Set.copyOf(mutableDyes); |
| 206 | + } |
178 | 207 | private final EventDispatcher eventDispatcher;
|
179 | 208 | private final WorldEdit worldEdit;
|
180 | 209 | private final PlotAreaManager plotAreaManager;
|
@@ -207,6 +236,38 @@ public PlayerEventListener(
|
207 | 236 | this.plotListener = plotListener;
|
208 | 237 | }
|
209 | 238 |
|
| 239 | + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) |
| 240 | + public void onPlayerDyeSign(PlayerInteractEvent event) { |
| 241 | + ItemStack itemStack = event.getItem(); |
| 242 | + if (itemStack == null) { |
| 243 | + return; |
| 244 | + } |
| 245 | + Block block = event.getClickedBlock(); |
| 246 | + if (block != null && block.getState() instanceof Sign) { |
| 247 | + if (DYES.contains(itemStack.getType().toString())) { |
| 248 | + Location location = BukkitUtil.adapt(block.getLocation()); |
| 249 | + PlotArea area = location.getPlotArea(); |
| 250 | + if (area == null) { |
| 251 | + return; |
| 252 | + } |
| 253 | + Plot plot = location.getOwnedPlot(); |
| 254 | + if (plot == null) { |
| 255 | + if (PlotFlagUtil.isAreaRoadFlagsAndFlagEquals(area, EditSignFlag.class, false)) { |
| 256 | + event.setCancelled(true); |
| 257 | + } |
| 258 | + return; |
| 259 | + } |
| 260 | + if (plot.isAdded(event.getPlayer().getUniqueId())) { |
| 261 | + return; // allow for added players |
| 262 | + } |
| 263 | + if (!plot.getFlag(EditSignFlag.class)) { |
| 264 | + plot.debug(event.getPlayer().getName() + " could not color the sign because of edit-sign = false"); |
| 265 | + event.setCancelled(true); |
| 266 | + } |
| 267 | + } |
| 268 | + } |
| 269 | + } |
| 270 | + |
210 | 271 | @EventHandler(ignoreCancelled = true)
|
211 | 272 | public void onEffect(@NonNull EntityPotionEffectEvent event) {
|
212 | 273 | if (Settings.Enabled_Components.DISABLE_BEACON_EFFECT_OVERFLOW ||
|
|
0 commit comments