001/* 002 * PlotSquared, a land and world management plugin for Minecraft. 003 * Copyright (C) IntellectualSites <https://intellectualsites.com> 004 * Copyright (C) IntellectualSites team and contributors 005 * 006 * This program is free software: you can redistribute it and/or modify 007 * it under the terms of the GNU General Public License as published by 008 * the Free Software Foundation, either version 3 of the License, or 009 * (at your option) any later version. 010 * 011 * This program is distributed in the hope that it will be useful, 012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 014 * GNU General Public License for more details. 015 * 016 * You should have received a copy of the GNU General Public License 017 * along with this program. If not, see <https://www.gnu.org/licenses/>. 018 */ 019package com.plotsquared.core.queue; 020 021import com.plotsquared.core.plot.PlotArea; 022import com.sk89q.jnbt.CompoundTag; 023import com.sk89q.worldedit.function.pattern.Pattern; 024import com.sk89q.worldedit.world.biome.BiomeType; 025import com.sk89q.worldedit.world.block.BaseBlock; 026import com.sk89q.worldedit.world.block.BlockState; 027import org.checkerframework.checker.nullness.qual.NonNull; 028import org.checkerframework.checker.nullness.qual.Nullable; 029 030import java.util.Objects; 031 032/** 033 * Queue Coordinator that only sets blocks with the specified PlotArea 034 */ 035public class AreaBoundDelegateQueueCoordinator extends DelegateQueueCoordinator { 036 037 private final PlotArea area; 038 039 public AreaBoundDelegateQueueCoordinator(final @NonNull PlotArea area, final @Nullable QueueCoordinator parent) { 040 super(parent); 041 this.area = Objects.requireNonNull(area); 042 } 043 044 /** 045 * Gets the plot area block settings is limited to 046 * 047 * @return PlotArea 048 */ 049 public PlotArea getArea() { 050 return this.area; 051 } 052 053 @Override 054 public boolean setBlock(int x, int y, int z, @NonNull BlockState id) { 055 if (area.contains(x, z)) { 056 return super.setBlock(x, y, z, id); 057 } 058 return false; 059 } 060 061 @Override 062 public boolean setBlock(int x, int y, int z, @NonNull BaseBlock id) { 063 if (area.contains(x, z)) { 064 return super.setBlock(x, y, z, id); 065 } 066 return false; 067 } 068 069 @Override 070 public boolean setBlock(int x, int y, int z, @NonNull Pattern pattern) { 071 if (area.contains(x, z)) { 072 return super.setBlock(x, y, z, pattern); 073 } 074 return false; 075 } 076 077 @Override 078 public boolean setBiome(int x, int z, @NonNull BiomeType biome) { 079 if (area.contains(x, z)) { 080 return super.setBiome(x, z, biome); 081 } 082 return false; 083 } 084 085 @Override 086 public boolean setBiome(int x, int y, int z, @NonNull BiomeType biome) { 087 if (area.contains(x, z)) { 088 return super.setBiome(x, y, z, biome); 089 } 090 return false; 091 } 092 093 @Override 094 public boolean setTile(int x, int y, int z, @NonNull CompoundTag tag) { 095 if (area.contains(x, z)) { 096 return super.setTile(x, y, z, tag); 097 } 098 return false; 099 } 100 101}