mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 13:16:45 +01:00
Fix the WE extent and add our own tile entity list
This commit is contained in:
parent
e6878d7804
commit
19fe2efb6e
@ -44,7 +44,10 @@ import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
|||||||
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockCategories;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
import io.papermc.lib.PaperLib;
|
import io.papermc.lib.PaperLib;
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -95,10 +98,12 @@ import java.util.ArrayList;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.IntConsumer;
|
import java.util.function.IntConsumer;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
@SuppressWarnings({"unused", "WeakerAccess"})
|
@SuppressWarnings({"unused", "WeakerAccess"})
|
||||||
public class BukkitUtil extends WorldUtil {
|
public class BukkitUtil extends WorldUtil {
|
||||||
@ -638,6 +643,32 @@ public class BukkitUtil extends WorldUtil {
|
|||||||
return types;
|
return types;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private final Collection<BlockType> tileEntityTypes = new HashSet<>();
|
||||||
|
@Override public Collection<BlockType> getTileEntityTypes() {
|
||||||
|
if (this.tileEntityTypes.isEmpty()) {
|
||||||
|
// Categories
|
||||||
|
tileEntityTypes.addAll(BlockCategories.BANNERS.getAll());
|
||||||
|
tileEntityTypes.addAll(BlockCategories.SIGNS.getAll());
|
||||||
|
tileEntityTypes.addAll(BlockCategories.BEDS.getAll());
|
||||||
|
tileEntityTypes.addAll(BlockCategories.FLOWER_POTS.getAll());
|
||||||
|
// Individual Types
|
||||||
|
// Add these from strings
|
||||||
|
Stream.of("barrel", "beacon", "beehive", "bell", "blast_furnace",
|
||||||
|
"brewing_stand", "campfire", "chest", "ender_chest", "trapped_chest",
|
||||||
|
"command_block", "end_gateway", "hopper", "jigsaw", "jubekox",
|
||||||
|
"lectern", "note_block", "black_shulker_box", "blue_shulker_box",
|
||||||
|
"brown_shulker_box", "cyan_shulker_box", "gray_shulker_box", "green_shulker_box",
|
||||||
|
"light_blue_shulker_box", "light_gray_shulker_box", "lime_shulker_box",
|
||||||
|
"magenta_shulker_box", "orange_shulker_box", "pink_shulker_box",
|
||||||
|
"purple_shulker_box", "red_shulker_box", "shulker_box", "white_shulker_box",
|
||||||
|
"yellow_shulker_box", "smoker", "structure")
|
||||||
|
.map(BlockTypes::get)
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.forEach(tileEntityTypes::add);
|
||||||
|
}
|
||||||
|
return this.tileEntityTypes;
|
||||||
|
}
|
||||||
|
|
||||||
private static void ensureLoaded(final String world, final int x, final int z,
|
private static void ensureLoaded(final String world, final int x, final int z,
|
||||||
final Consumer<Chunk> chunkConsumer) {
|
final Consumer<Chunk> chunkConsumer) {
|
||||||
PaperLib.getChunkAtAsync(getWorld(world), x >> 4, z >> 4, true)
|
PaperLib.getChunkAtAsync(getWorld(world), x >> 4, z >> 4, true)
|
||||||
|
@ -96,7 +96,8 @@ public class Set extends SubCommand {
|
|||||||
|
|
||||||
if (blockType.startsWith("##")) {
|
if (blockType.startsWith("##")) {
|
||||||
try {
|
try {
|
||||||
final BlockCategory category = BlockCategory.REGISTRY.get(blockType.substring(2).toLowerCase(Locale.ENGLISH));
|
final BlockCategory category = BlockCategory.REGISTRY.get(blockType.substring(2)
|
||||||
|
.replaceAll("[*^|]+", "").toLowerCase(Locale.ENGLISH));
|
||||||
if (category == null || !category.contains(BlockTypes.get(forbiddenType))) {
|
if (category == null || !category.contains(BlockTypes.get(forbiddenType))) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,7 @@ import com.plotsquared.core.PlotSquared;
|
|||||||
import com.plotsquared.core.configuration.Captions;
|
import com.plotsquared.core.configuration.Captions;
|
||||||
import com.plotsquared.core.configuration.Settings;
|
import com.plotsquared.core.configuration.Settings;
|
||||||
import com.plotsquared.core.util.WEManager;
|
import com.plotsquared.core.util.WEManager;
|
||||||
|
import com.plotsquared.core.util.WorldUtil;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.entity.BaseEntity;
|
import com.sk89q.worldedit.entity.BaseEntity;
|
||||||
import com.sk89q.worldedit.entity.Entity;
|
import com.sk89q.worldedit.entity.Entity;
|
||||||
@ -90,12 +91,12 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
|
|||||||
public <T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 location, T block)
|
public <T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 location, T block)
|
||||||
throws WorldEditException {
|
throws WorldEditException {
|
||||||
|
|
||||||
final boolean isTile = block.toBaseBlock().getNbtData() != null;
|
final boolean isTile = WorldUtil.IMP.getTileEntityTypes().contains(block.getBlockType());
|
||||||
if (isTile) {
|
if (isTile) {
|
||||||
if (this.BSblocked) {
|
if (this.BSblocked) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (++this.BScount > Settings.Chunk_Processor.MAX_TILES) {
|
if (++this.BScount >= Settings.Chunk_Processor.MAX_TILES) {
|
||||||
this.BSblocked = true;
|
this.BSblocked = true;
|
||||||
PlotSquared.debug(Captions.PREFIX + "&cDetected unsafe WorldEdit: " + location.getX() + ","
|
PlotSquared.debug(Captions.PREFIX + "&cDetected unsafe WorldEdit: " + location.getX() + ","
|
||||||
+ location.getZ());
|
+ location.getZ());
|
||||||
|
@ -39,6 +39,7 @@ import com.sk89q.worldedit.math.BlockVector2;
|
|||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
import com.sk89q.worldedit.world.entity.EntityType;
|
import com.sk89q.worldedit.world.entity.EntityType;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@ -48,6 +49,7 @@ import java.io.FileInputStream;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -216,4 +218,6 @@ public abstract class WorldUtil {
|
|||||||
|
|
||||||
public abstract Set<EntityType> getTypesInCategory(final String category);
|
public abstract Set<EntityType> getTypesInCategory(final String category);
|
||||||
|
|
||||||
|
public abstract Collection<BlockType> getTileEntityTypes();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user