Plex-FAWE/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitAdapter.java

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

499 lines
15 KiB
Java
Raw Normal View History

/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit 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.sk89q.worldedit.bukkit;
import com.fastasyncworldedit.bukkit.adapter.IBukkitAdapter;
import com.fastasyncworldedit.bukkit.adapter.SimpleBukkitAdapter;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.blocks.BaseItemStack;
2018-08-27 16:56:28 +00:00
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.extension.input.ParserContext;
import com.sk89q.worldedit.extension.platform.Actor;
2019-10-23 04:23:52 +00:00
import com.sk89q.worldedit.extension.platform.PlayerProxy;
2018-12-23 16:19:33 +00:00
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.util.Direction;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.World;
2019-02-16 07:27:00 +00:00
import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockType;
2018-08-13 12:29:48 +00:00
import com.sk89q.worldedit.world.entity.EntityType;
2018-07-22 05:36:50 +00:00
import com.sk89q.worldedit.world.gamemode.GameMode;
import com.sk89q.worldedit.world.item.ItemType;
2020-03-24 16:15:24 +00:00
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import org.bukkit.Material;
2019-02-16 07:27:00 +00:00
import org.bukkit.block.Biome;
import org.bukkit.block.BlockFace;
import org.bukkit.block.data.BlockData;
import org.bukkit.command.CommandSender;
2018-08-03 13:01:56 +00:00
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* Adapts between Bukkit and WorldEdit equivalent objects.
*/
Feature/propagate diff and object cleanup (#1190) * Feature/main/propagate diff annotations (#1187) * 25% done * More work * More work * 50% * More work * 75% * 100% & cleanup * Update adapters * Squish squash, applesauce commit 275ba9bd8424270b513009e24123df5d158b1990 Author: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Date: Sat Jul 17 01:10:20 2021 +0200 Update dependency com.comphenix.protocol:ProtocolLib to v4.7.0 (#1173) Co-authored-by: Renovate Bot <bot@renovateapp.com> commit 9fd898480419ebe7c57e59caf56b8cf34fef0aae Author: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Date: Sat Jul 17 01:09:29 2021 +0200 Update dependency org.checkerframework:checker-qual to v3.16.0 (#1184) Co-authored-by: Renovate Bot <bot@renovateapp.com> commit 861fb45e5c8d3c82a0d9fdb270f8ebe3ebbafac4 Author: dordsor21 <dordsor21@gmail.com> Date: Fri Jul 16 19:07:02 2021 +0100 Fix #1075 commit 420c45a29ac8a2cdd0110e9a9b225abf9e726a26 Author: dordsor21 <dordsor21@gmail.com> Date: Fri Jul 16 18:48:21 2021 +0100 Entity removal should be on the main thread as we're just passing through rather than doing chunk operations - Fixes #1164 - Not working: butcher/remove history commit 4d4db7dcd0c2ce99d59c32072247f0fc61fd27f6 Author: SirYwell <hannesgreule@outlook.de> Date: Fri Jul 16 17:52:44 2021 +0200 Make sure leaves category is loaded for heightmaps (fixes #1176) commit c98f6e4f37e256133bdee5179cb1c319d8c2c203 Author: dordsor21 <dordsor21@gmail.com> Date: Fri Jul 16 10:44:52 2021 +0100 Do not allow generation commands to generate outside selection commit 2485f5eccc875faff9730b5107e2559612042bad Author: dordsor21 <dordsor21@gmail.com> Date: Fri Jul 16 10:43:15 2021 +0100 EditSession needs to override some Extent methods to ensure block changes are correctly set through the various extents Fixes #1152 commit d9418ec8aefaa3f843f61babf87c40e01502a9e1 Author: dordsor21 <dordsor21@gmail.com> Date: Fri Jul 16 09:52:44 2021 +0100 Undo part of 41073bb1a0f73c58308cad13c9206ca16ed67831 Fixes #1178 * Update Upstream fb1fb84 Fixed typo and grammar * We don't support custom heights yet * Casing inconsistency * Address a few comments * Address comments * Don't refactor to AP classpath * Document annotation style * Refactoring & shade cleanup * Address a few comments * More work * Resolve comments not being resolved yet * Feature/main/propagate diff annotations (#1187) (#1194) * Remove beta package, fix history packages, move classes out of object package * Resolve comments not being resolved yet * Remove beta package, fix history packages, move classes out of object package Co-authored-by: NotMyFault <mc.cache@web.de> * brushes should be under brush * More refactoring - Filters/processors should be in the same place and are related to extents - Transforms are in `extent.transform` in upstream * Move history classes under history * Update adapters Co-authored-by: dordsor21 <dordsor21@gmail.com>
2021-07-23 15:48:51 +00:00
//FAWE start - enum-ized
2018-08-27 16:56:28 +00:00
public enum BukkitAdapter {
2019-06-06 22:39:51 +00:00
INSTANCE;
2018-08-27 16:56:28 +00:00
private final IBukkitAdapter adapter;
BukkitAdapter() {
BukkitImplAdapter tmp = WorldEditPlugin.getInstance().getBukkitImplAdapter();
this.adapter = Objects.requireNonNullElseGet(tmp, SimpleBukkitAdapter::new);
2018-08-27 16:56:28 +00:00
}
private static IBukkitAdapter getAdapter() {
2018-08-27 16:56:28 +00:00
return INSTANCE.adapter;
}
Feature/propagate diff and object cleanup (#1190) * Feature/main/propagate diff annotations (#1187) * 25% done * More work * More work * 50% * More work * 75% * 100% & cleanup * Update adapters * Squish squash, applesauce commit 275ba9bd8424270b513009e24123df5d158b1990 Author: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Date: Sat Jul 17 01:10:20 2021 +0200 Update dependency com.comphenix.protocol:ProtocolLib to v4.7.0 (#1173) Co-authored-by: Renovate Bot <bot@renovateapp.com> commit 9fd898480419ebe7c57e59caf56b8cf34fef0aae Author: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Date: Sat Jul 17 01:09:29 2021 +0200 Update dependency org.checkerframework:checker-qual to v3.16.0 (#1184) Co-authored-by: Renovate Bot <bot@renovateapp.com> commit 861fb45e5c8d3c82a0d9fdb270f8ebe3ebbafac4 Author: dordsor21 <dordsor21@gmail.com> Date: Fri Jul 16 19:07:02 2021 +0100 Fix #1075 commit 420c45a29ac8a2cdd0110e9a9b225abf9e726a26 Author: dordsor21 <dordsor21@gmail.com> Date: Fri Jul 16 18:48:21 2021 +0100 Entity removal should be on the main thread as we're just passing through rather than doing chunk operations - Fixes #1164 - Not working: butcher/remove history commit 4d4db7dcd0c2ce99d59c32072247f0fc61fd27f6 Author: SirYwell <hannesgreule@outlook.de> Date: Fri Jul 16 17:52:44 2021 +0200 Make sure leaves category is loaded for heightmaps (fixes #1176) commit c98f6e4f37e256133bdee5179cb1c319d8c2c203 Author: dordsor21 <dordsor21@gmail.com> Date: Fri Jul 16 10:44:52 2021 +0100 Do not allow generation commands to generate outside selection commit 2485f5eccc875faff9730b5107e2559612042bad Author: dordsor21 <dordsor21@gmail.com> Date: Fri Jul 16 10:43:15 2021 +0100 EditSession needs to override some Extent methods to ensure block changes are correctly set through the various extents Fixes #1152 commit d9418ec8aefaa3f843f61babf87c40e01502a9e1 Author: dordsor21 <dordsor21@gmail.com> Date: Fri Jul 16 09:52:44 2021 +0100 Undo part of 41073bb1a0f73c58308cad13c9206ca16ed67831 Fixes #1178 * Update Upstream fb1fb84 Fixed typo and grammar * We don't support custom heights yet * Casing inconsistency * Address a few comments * Address comments * Don't refactor to AP classpath * Document annotation style * Refactoring & shade cleanup * Address a few comments * More work * Resolve comments not being resolved yet * Feature/main/propagate diff annotations (#1187) (#1194) * Remove beta package, fix history packages, move classes out of object package * Resolve comments not being resolved yet * Remove beta package, fix history packages, move classes out of object package Co-authored-by: NotMyFault <mc.cache@web.de> * brushes should be under brush * More refactoring - Filters/processors should be in the same place and are related to extents - Transforms are in `extent.transform` in upstream * Move history classes under history * Update adapters Co-authored-by: dordsor21 <dordsor21@gmail.com>
2021-07-23 15:48:51 +00:00
//FAWE end
private static final ParserContext TO_BLOCK_CONTEXT = new ParserContext();
static {
TO_BLOCK_CONTEXT.setRestricted(false);
}
2019-06-06 22:39:51 +00:00
/**
* Checks equality between a WorldEdit BlockType and a Bukkit Material.
2019-06-06 22:39:51 +00:00
*
* @param blockType The WorldEdit BlockType
* @param type The Bukkit Material
2019-06-06 22:39:51 +00:00
* @return If they are equal
*/
public static boolean equals(BlockType blockType, Material type) {
Feature/propagate diff and object cleanup (#1190) * Feature/main/propagate diff annotations (#1187) * 25% done * More work * More work * 50% * More work * 75% * 100% & cleanup * Update adapters * Squish squash, applesauce commit 275ba9bd8424270b513009e24123df5d158b1990 Author: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Date: Sat Jul 17 01:10:20 2021 +0200 Update dependency com.comphenix.protocol:ProtocolLib to v4.7.0 (#1173) Co-authored-by: Renovate Bot <bot@renovateapp.com> commit 9fd898480419ebe7c57e59caf56b8cf34fef0aae Author: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Date: Sat Jul 17 01:09:29 2021 +0200 Update dependency org.checkerframework:checker-qual to v3.16.0 (#1184) Co-authored-by: Renovate Bot <bot@renovateapp.com> commit 861fb45e5c8d3c82a0d9fdb270f8ebe3ebbafac4 Author: dordsor21 <dordsor21@gmail.com> Date: Fri Jul 16 19:07:02 2021 +0100 Fix #1075 commit 420c45a29ac8a2cdd0110e9a9b225abf9e726a26 Author: dordsor21 <dordsor21@gmail.com> Date: Fri Jul 16 18:48:21 2021 +0100 Entity removal should be on the main thread as we're just passing through rather than doing chunk operations - Fixes #1164 - Not working: butcher/remove history commit 4d4db7dcd0c2ce99d59c32072247f0fc61fd27f6 Author: SirYwell <hannesgreule@outlook.de> Date: Fri Jul 16 17:52:44 2021 +0200 Make sure leaves category is loaded for heightmaps (fixes #1176) commit c98f6e4f37e256133bdee5179cb1c319d8c2c203 Author: dordsor21 <dordsor21@gmail.com> Date: Fri Jul 16 10:44:52 2021 +0100 Do not allow generation commands to generate outside selection commit 2485f5eccc875faff9730b5107e2559612042bad Author: dordsor21 <dordsor21@gmail.com> Date: Fri Jul 16 10:43:15 2021 +0100 EditSession needs to override some Extent methods to ensure block changes are correctly set through the various extents Fixes #1152 commit d9418ec8aefaa3f843f61babf87c40e01502a9e1 Author: dordsor21 <dordsor21@gmail.com> Date: Fri Jul 16 09:52:44 2021 +0100 Undo part of 41073bb1a0f73c58308cad13c9206ca16ed67831 Fixes #1178 * Update Upstream fb1fb84 Fixed typo and grammar * We don't support custom heights yet * Casing inconsistency * Address a few comments * Address comments * Don't refactor to AP classpath * Document annotation style * Refactoring & shade cleanup * Address a few comments * More work * Resolve comments not being resolved yet * Feature/main/propagate diff annotations (#1187) (#1194) * Remove beta package, fix history packages, move classes out of object package * Resolve comments not being resolved yet * Remove beta package, fix history packages, move classes out of object package Co-authored-by: NotMyFault <mc.cache@web.de> * brushes should be under brush * More refactoring - Filters/processors should be in the same place and are related to extents - Transforms are in `extent.transform` in upstream * Move history classes under history * Update adapters Co-authored-by: dordsor21 <dordsor21@gmail.com>
2021-07-23 15:48:51 +00:00
//FAWE start - swapped reference to getAdapter
2019-10-23 04:23:52 +00:00
return getAdapter().equals(blockType, type);
Feature/propagate diff and object cleanup (#1190) * Feature/main/propagate diff annotations (#1187) * 25% done * More work * More work * 50% * More work * 75% * 100% & cleanup * Update adapters * Squish squash, applesauce commit 275ba9bd8424270b513009e24123df5d158b1990 Author: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Date: Sat Jul 17 01:10:20 2021 +0200 Update dependency com.comphenix.protocol:ProtocolLib to v4.7.0 (#1173) Co-authored-by: Renovate Bot <bot@renovateapp.com> commit 9fd898480419ebe7c57e59caf56b8cf34fef0aae Author: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Date: Sat Jul 17 01:09:29 2021 +0200 Update dependency org.checkerframework:checker-qual to v3.16.0 (#1184) Co-authored-by: Renovate Bot <bot@renovateapp.com> commit 861fb45e5c8d3c82a0d9fdb270f8ebe3ebbafac4 Author: dordsor21 <dordsor21@gmail.com> Date: Fri Jul 16 19:07:02 2021 +0100 Fix #1075 commit 420c45a29ac8a2cdd0110e9a9b225abf9e726a26 Author: dordsor21 <dordsor21@gmail.com> Date: Fri Jul 16 18:48:21 2021 +0100 Entity removal should be on the main thread as we're just passing through rather than doing chunk operations - Fixes #1164 - Not working: butcher/remove history commit 4d4db7dcd0c2ce99d59c32072247f0fc61fd27f6 Author: SirYwell <hannesgreule@outlook.de> Date: Fri Jul 16 17:52:44 2021 +0200 Make sure leaves category is loaded for heightmaps (fixes #1176) commit c98f6e4f37e256133bdee5179cb1c319d8c2c203 Author: dordsor21 <dordsor21@gmail.com> Date: Fri Jul 16 10:44:52 2021 +0100 Do not allow generation commands to generate outside selection commit 2485f5eccc875faff9730b5107e2559612042bad Author: dordsor21 <dordsor21@gmail.com> Date: Fri Jul 16 10:43:15 2021 +0100 EditSession needs to override some Extent methods to ensure block changes are correctly set through the various extents Fixes #1152 commit d9418ec8aefaa3f843f61babf87c40e01502a9e1 Author: dordsor21 <dordsor21@gmail.com> Date: Fri Jul 16 09:52:44 2021 +0100 Undo part of 41073bb1a0f73c58308cad13c9206ca16ed67831 Fixes #1178 * Update Upstream fb1fb84 Fixed typo and grammar * We don't support custom heights yet * Casing inconsistency * Address a few comments * Address comments * Don't refactor to AP classpath * Document annotation style * Refactoring & shade cleanup * Address a few comments * More work * Resolve comments not being resolved yet * Feature/main/propagate diff annotations (#1187) (#1194) * Remove beta package, fix history packages, move classes out of object package * Resolve comments not being resolved yet * Remove beta package, fix history packages, move classes out of object package Co-authored-by: NotMyFault <mc.cache@web.de> * brushes should be under brush * More refactoring - Filters/processors should be in the same place and are related to extents - Transforms are in `extent.transform` in upstream * Move history classes under history * Update adapters Co-authored-by: dordsor21 <dordsor21@gmail.com>
2021-07-23 15:48:51 +00:00
//FAWE end
}
2019-06-06 22:39:51 +00:00
/**
* Convert any WorldEdit world into an equivalent wrapped Bukkit world.
*
* <p>If a matching world cannot be found, a {@link RuntimeException}
* will be thrown.</p>
*
* @param world the world
* @return a wrapped Bukkit world
*/
public static BukkitWorld asBukkitWorld(World world) {
Feature/propagate diff and object cleanup (#1190) * Feature/main/propagate diff annotations (#1187) * 25% done * More work * More work * 50% * More work * 75% * 100% & cleanup * Update adapters * Squish squash, applesauce commit 275ba9bd8424270b513009e24123df5d158b1990 Author: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Date: Sat Jul 17 01:10:20 2021 +0200 Update dependency com.comphenix.protocol:ProtocolLib to v4.7.0 (#1173) Co-authored-by: Renovate Bot <bot@renovateapp.com> commit 9fd898480419ebe7c57e59caf56b8cf34fef0aae Author: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Date: Sat Jul 17 01:09:29 2021 +0200 Update dependency org.checkerframework:checker-qual to v3.16.0 (#1184) Co-authored-by: Renovate Bot <bot@renovateapp.com> commit 861fb45e5c8d3c82a0d9fdb270f8ebe3ebbafac4 Author: dordsor21 <dordsor21@gmail.com> Date: Fri Jul 16 19:07:02 2021 +0100 Fix #1075 commit 420c45a29ac8a2cdd0110e9a9b225abf9e726a26 Author: dordsor21 <dordsor21@gmail.com> Date: Fri Jul 16 18:48:21 2021 +0100 Entity removal should be on the main thread as we're just passing through rather than doing chunk operations - Fixes #1164 - Not working: butcher/remove history commit 4d4db7dcd0c2ce99d59c32072247f0fc61fd27f6 Author: SirYwell <hannesgreule@outlook.de> Date: Fri Jul 16 17:52:44 2021 +0200 Make sure leaves category is loaded for heightmaps (fixes #1176) commit c98f6e4f37e256133bdee5179cb1c319d8c2c203 Author: dordsor21 <dordsor21@gmail.com> Date: Fri Jul 16 10:44:52 2021 +0100 Do not allow generation commands to generate outside selection commit 2485f5eccc875faff9730b5107e2559612042bad Author: dordsor21 <dordsor21@gmail.com> Date: Fri Jul 16 10:43:15 2021 +0100 EditSession needs to override some Extent methods to ensure block changes are correctly set through the various extents Fixes #1152 commit d9418ec8aefaa3f843f61babf87c40e01502a9e1 Author: dordsor21 <dordsor21@gmail.com> Date: Fri Jul 16 09:52:44 2021 +0100 Undo part of 41073bb1a0f73c58308cad13c9206ca16ed67831 Fixes #1178 * Update Upstream fb1fb84 Fixed typo and grammar * We don't support custom heights yet * Casing inconsistency * Address a few comments * Address comments * Don't refactor to AP classpath * Document annotation style * Refactoring & shade cleanup * Address a few comments * More work * Resolve comments not being resolved yet * Feature/main/propagate diff annotations (#1187) (#1194) * Remove beta package, fix history packages, move classes out of object package * Resolve comments not being resolved yet * Remove beta package, fix history packages, move classes out of object package Co-authored-by: NotMyFault <mc.cache@web.de> * brushes should be under brush * More refactoring - Filters/processors should be in the same place and are related to extents - Transforms are in `extent.transform` in upstream * Move history classes under history * Update adapters Co-authored-by: dordsor21 <dordsor21@gmail.com>
2021-07-23 15:48:51 +00:00
//FAWE start - logic moved to IBukkitAdapter
2019-10-23 04:23:52 +00:00
return getAdapter().asBukkitWorld(world);
Feature/propagate diff and object cleanup (#1190) * Feature/main/propagate diff annotations (#1187) * 25% done * More work * More work * 50% * More work * 75% * 100% & cleanup * Update adapters * Squish squash, applesauce commit 275ba9bd8424270b513009e24123df5d158b1990 Author: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Date: Sat Jul 17 01:10:20 2021 +0200 Update dependency com.comphenix.protocol:ProtocolLib to v4.7.0 (#1173) Co-authored-by: Renovate Bot <bot@renovateapp.com> commit 9fd898480419ebe7c57e59caf56b8cf34fef0aae Author: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Date: Sat Jul 17 01:09:29 2021 +0200 Update dependency org.checkerframework:checker-qual to v3.16.0 (#1184) Co-authored-by: Renovate Bot <bot@renovateapp.com> commit 861fb45e5c8d3c82a0d9fdb270f8ebe3ebbafac4 Author: dordsor21 <dordsor21@gmail.com> Date: Fri Jul 16 19:07:02 2021 +0100 Fix #1075 commit 420c45a29ac8a2cdd0110e9a9b225abf9e726a26 Author: dordsor21 <dordsor21@gmail.com> Date: Fri Jul 16 18:48:21 2021 +0100 Entity removal should be on the main thread as we're just passing through rather than doing chunk operations - Fixes #1164 - Not working: butcher/remove history commit 4d4db7dcd0c2ce99d59c32072247f0fc61fd27f6 Author: SirYwell <hannesgreule@outlook.de> Date: Fri Jul 16 17:52:44 2021 +0200 Make sure leaves category is loaded for heightmaps (fixes #1176) commit c98f6e4f37e256133bdee5179cb1c319d8c2c203 Author: dordsor21 <dordsor21@gmail.com> Date: Fri Jul 16 10:44:52 2021 +0100 Do not allow generation commands to generate outside selection commit 2485f5eccc875faff9730b5107e2559612042bad Author: dordsor21 <dordsor21@gmail.com> Date: Fri Jul 16 10:43:15 2021 +0100 EditSession needs to override some Extent methods to ensure block changes are correctly set through the various extents Fixes #1152 commit d9418ec8aefaa3f843f61babf87c40e01502a9e1 Author: dordsor21 <dordsor21@gmail.com> Date: Fri Jul 16 09:52:44 2021 +0100 Undo part of 41073bb1a0f73c58308cad13c9206ca16ed67831 Fixes #1178 * Update Upstream fb1fb84 Fixed typo and grammar * We don't support custom heights yet * Casing inconsistency * Address a few comments * Address comments * Don't refactor to AP classpath * Document annotation style * Refactoring & shade cleanup * Address a few comments * More work * Resolve comments not being resolved yet * Feature/main/propagate diff annotations (#1187) (#1194) * Remove beta package, fix history packages, move classes out of object package * Resolve comments not being resolved yet * Remove beta package, fix history packages, move classes out of object package Co-authored-by: NotMyFault <mc.cache@web.de> * brushes should be under brush * More refactoring - Filters/processors should be in the same place and are related to extents - Transforms are in `extent.transform` in upstream * Move history classes under history * Update adapters Co-authored-by: dordsor21 <dordsor21@gmail.com>
2021-07-23 15:48:51 +00:00
//FAWE end
}
2019-06-06 22:39:51 +00:00
/**
* Create a WorldEdit world from a Bukkit world.
*
* @param world the Bukkit world
* @return a WorldEdit world
*/
public static World adapt(org.bukkit.World world) {
Feature/propagate diff and object cleanup (#1190) * Feature/main/propagate diff annotations (#1187) * 25% done * More work * More work * 50% * More work * 75% * 100% & cleanup * Update adapters * Squish squash, applesauce commit 275ba9bd8424270b513009e24123df5d158b1990 Author: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Date: Sat Jul 17 01:10:20 2021 +0200 Update dependency com.comphenix.protocol:ProtocolLib to v4.7.0 (#1173) Co-authored-by: Renovate Bot <bot@renovateapp.com> commit 9fd898480419ebe7c57e59caf56b8cf34fef0aae Author: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Date: Sat Jul 17 01:09:29 2021 +0200 Update dependency org.checkerframework:checker-qual to v3.16.0 (#1184) Co-authored-by: Renovate Bot <bot@renovateapp.com> commit 861fb45e5c8d3c82a0d9fdb270f8ebe3ebbafac4 Author: dordsor21 <dordsor21@gmail.com> Date: Fri Jul 16 19:07:02 2021 +0100 Fix #1075 commit 420c45a29ac8a2cdd0110e9a9b225abf9e726a26 Author: dordsor21 <dordsor21@gmail.com> Date: Fri Jul 16 18:48:21 2021 +0100 Entity removal should be on the main thread as we're just passing through rather than doing chunk operations - Fixes #1164 - Not working: butcher/remove history commit 4d4db7dcd0c2ce99d59c32072247f0fc61fd27f6 Author: SirYwell <hannesgreule@outlook.de> Date: Fri Jul 16 17:52:44 2021 +0200 Make sure leaves category is loaded for heightmaps (fixes #1176) commit c98f6e4f37e256133bdee5179cb1c319d8c2c203 Author: dordsor21 <dordsor21@gmail.com> Date: Fri Jul 16 10:44:52 2021 +0100 Do not allow generation commands to generate outside selection commit 2485f5eccc875faff9730b5107e2559612042bad Author: dordsor21 <dordsor21@gmail.com> Date: Fri Jul 16 10:43:15 2021 +0100 EditSession needs to override some Extent methods to ensure block changes are correctly set through the various extents Fixes #1152 commit d9418ec8aefaa3f843f61babf87c40e01502a9e1 Author: dordsor21 <dordsor21@gmail.com> Date: Fri Jul 16 09:52:44 2021 +0100 Undo part of 41073bb1a0f73c58308cad13c9206ca16ed67831 Fixes #1178 * Update Upstream fb1fb84 Fixed typo and grammar * We don't support custom heights yet * Casing inconsistency * Address a few comments * Address comments * Don't refactor to AP classpath * Document annotation style * Refactoring & shade cleanup * Address a few comments * More work * Resolve comments not being resolved yet * Feature/main/propagate diff annotations (#1187) (#1194) * Remove beta package, fix history packages, move classes out of object package * Resolve comments not being resolved yet * Remove beta package, fix history packages, move classes out of object package Co-authored-by: NotMyFault <mc.cache@web.de> * brushes should be under brush * More refactoring - Filters/processors should be in the same place and are related to extents - Transforms are in `extent.transform` in upstream * Move history classes under history * Update adapters Co-authored-by: dordsor21 <dordsor21@gmail.com>
2021-07-23 15:48:51 +00:00
//FAWE start - logic moved to IBukkitAdapter
2019-10-23 04:23:52 +00:00
return getAdapter().adapt(world);
Feature/propagate diff and object cleanup (#1190) * Feature/main/propagate diff annotations (#1187) * 25% done * More work * More work * 50% * More work * 75% * 100% & cleanup * Update adapters * Squish squash, applesauce commit 275ba9bd8424270b513009e24123df5d158b1990 Author: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Date: Sat Jul 17 01:10:20 2021 +0200 Update dependency com.comphenix.protocol:ProtocolLib to v4.7.0 (#1173) Co-authored-by: Renovate Bot <bot@renovateapp.com> commit 9fd898480419ebe7c57e59caf56b8cf34fef0aae Author: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Date: Sat Jul 17 01:09:29 2021 +0200 Update dependency org.checkerframework:checker-qual to v3.16.0 (#1184) Co-authored-by: Renovate Bot <bot@renovateapp.com> commit 861fb45e5c8d3c82a0d9fdb270f8ebe3ebbafac4 Author: dordsor21 <dordsor21@gmail.com> Date: Fri Jul 16 19:07:02 2021 +0100 Fix #1075 commit 420c45a29ac8a2cdd0110e9a9b225abf9e726a26 Author: dordsor21 <dordsor21@gmail.com> Date: Fri Jul 16 18:48:21 2021 +0100 Entity removal should be on the main thread as we're just passing through rather than doing chunk operations - Fixes #1164 - Not working: butcher/remove history commit 4d4db7dcd0c2ce99d59c32072247f0fc61fd27f6 Author: SirYwell <hannesgreule@outlook.de> Date: Fri Jul 16 17:52:44 2021 +0200 Make sure leaves category is loaded for heightmaps (fixes #1176) commit c98f6e4f37e256133bdee5179cb1c319d8c2c203 Author: dordsor21 <dordsor21@gmail.com> Date: Fri Jul 16 10:44:52 2021 +0100 Do not allow generation commands to generate outside selection commit 2485f5eccc875faff9730b5107e2559612042bad Author: dordsor21 <dordsor21@gmail.com> Date: Fri Jul 16 10:43:15 2021 +0100 EditSession needs to override some Extent methods to ensure block changes are correctly set through the various extents Fixes #1152 commit d9418ec8aefaa3f843f61babf87c40e01502a9e1 Author: dordsor21 <dordsor21@gmail.com> Date: Fri Jul 16 09:52:44 2021 +0100 Undo part of 41073bb1a0f73c58308cad13c9206ca16ed67831 Fixes #1178 * Update Upstream fb1fb84 Fixed typo and grammar * We don't support custom heights yet * Casing inconsistency * Address a few comments * Address comments * Don't refactor to AP classpath * Document annotation style * Refactoring & shade cleanup * Address a few comments * More work * Resolve comments not being resolved yet * Feature/main/propagate diff annotations (#1187) (#1194) * Remove beta package, fix history packages, move classes out of object package * Resolve comments not being resolved yet * Remove beta package, fix history packages, move classes out of object package Co-authored-by: NotMyFault <mc.cache@web.de> * brushes should be under brush * More refactoring - Filters/processors should be in the same place and are related to extents - Transforms are in `extent.transform` in upstream * Move history classes under history * Update adapters Co-authored-by: dordsor21 <dordsor21@gmail.com>
2021-07-23 15:48:51 +00:00
//FAWE end
}
/**
* Create a WorldEdit Actor from a Bukkit CommandSender.
*
* @param sender The Bukkit CommandSender
* @return The WorldEdit Actor
*/
public static Actor adapt(CommandSender sender) {
return WorldEditPlugin.getInstance().wrapCommandSender(sender);
}
/**
* Create a WorldEdit Player from a Bukkit Player.
*
* @param player The Bukkit player
* @return The WorldEdit player
*/
public static BukkitPlayer adapt(Player player) {
2019-09-21 01:52:35 +00:00
return WorldEditPlugin.getInstance().wrapPlayer(player);
}
/**
* Create a Bukkit CommandSender from a WorldEdit Actor.
*
* @param actor The WorldEdit actor
* @return The Bukkit command sender
*/
public static CommandSender adapt(Actor actor) {
if (actor instanceof com.sk89q.worldedit.entity.Player) {
return adapt((com.sk89q.worldedit.entity.Player) actor);
} else if (actor instanceof BukkitBlockCommandSender) {
return ((BukkitBlockCommandSender) actor).getSender();
}
return ((BukkitCommandSender) actor).getSender();
}
/**
* Create a Bukkit Player from a WorldEdit Player.
*
* @param player The WorldEdit player
* @return The Bukkit player
*/
public static Player adapt(com.sk89q.worldedit.entity.Player player) {
//FAWE start - Get player from PlayerProxy instead of BukkitPlayer if null
2019-10-23 04:23:52 +00:00
player = PlayerProxy.unwrap(player);
return player == null ? null : ((BukkitPlayer) player).getPlayer();
//FAWE end
}
/**
* Create a WorldEdit Direction from a Bukkit BlockFace.
*
* @param face the Bukkit BlockFace
* @return a WorldEdit direction
*/
public static Direction adapt(@Nullable BlockFace face) {
if (face == null) {
return null;
}
switch (face) {
case NORTH:
return Direction.NORTH;
case SOUTH:
return Direction.SOUTH;
case WEST:
return Direction.WEST;
case EAST:
return Direction.EAST;
case DOWN:
return Direction.DOWN;
case UP:
default:
return Direction.UP;
}
2019-09-21 01:52:35 +00:00
}
/**
* Create a Bukkit world from a WorldEdit world.
*
* @param world the WorldEdit world
* @return a Bukkit world
*/
public static org.bukkit.World adapt(World world) {
//FAWE start - logic moved to IBukkitAdapter
2019-10-23 04:23:52 +00:00
return getAdapter().adapt(world);
//FAWE end
}
2019-06-06 22:39:51 +00:00
/**
* Create a WorldEdit location from a Bukkit location.
*
* @param location the Bukkit location
* @return a WorldEdit location
*/
public static Location adapt(org.bukkit.Location location) {
2019-06-06 22:39:51 +00:00
checkNotNull(location);
2019-09-21 01:52:35 +00:00
Vector3 position = asVector(location);
return new com.sk89q.worldedit.util.Location(
adapt(location.getWorld()),
position,
location.getYaw(),
location.getPitch()
);
}
2019-06-06 22:39:51 +00:00
/**
* Create a Bukkit location from a WorldEdit location.
*
* @param location the WorldEdit location
* @return a Bukkit location
*/
public static org.bukkit.Location adapt(Location location) {
2019-06-06 22:39:51 +00:00
checkNotNull(location);
2019-09-21 01:52:35 +00:00
Vector3 position = location;
return new org.bukkit.Location(
adapt((World) location.getExtent()),
position.getX(), position.getY(), position.getZ(),
location.getYaw(),
location.getPitch()
);
}
/**
* Create a Bukkit location from a WorldEdit position with a Bukkit world.
*
* @param world the Bukkit world
* @param position the WorldEdit position
* @return a Bukkit location
*/
2018-12-23 16:19:33 +00:00
public static org.bukkit.Location adapt(org.bukkit.World world, Vector3 position) {
2019-09-21 01:52:35 +00:00
checkNotNull(world);
checkNotNull(position);
return new org.bukkit.Location(
world,
position.getX(), position.getY(), position.getZ()
);
2018-12-23 16:19:33 +00:00
}
2019-06-06 22:39:51 +00:00
/**
* Create a Bukkit location from a WorldEdit position with a Bukkit world.
*
* @param world the Bukkit world
* @param position the WorldEdit position
* @return a Bukkit location
*/
2018-12-23 16:19:33 +00:00
public static org.bukkit.Location adapt(org.bukkit.World world, BlockVector3 position) {
2019-06-06 22:39:51 +00:00
checkNotNull(world);
checkNotNull(position);
2019-09-21 01:52:35 +00:00
return new org.bukkit.Location(
world,
position.getX(), position.getY(), position.getZ()
);
}
2019-06-06 22:39:51 +00:00
/**
* Create a Bukkit location from a WorldEdit location with a Bukkit world.
*
* @param world the Bukkit world
2019-06-06 22:39:51 +00:00
* @param location the WorldEdit location
* @return a Bukkit location
*/
2014-07-15 01:11:38 +00:00
public static org.bukkit.Location adapt(org.bukkit.World world, Location location) {
2019-06-06 22:39:51 +00:00
checkNotNull(world);
checkNotNull(location);
2019-09-21 01:52:35 +00:00
return new org.bukkit.Location(
world,
location.getX(), location.getY(), location.getZ(),
location.getYaw(),
location.getPitch()
);
2014-07-15 01:11:38 +00:00
}
/**
* Create a WorldEdit Vector from a Bukkit location.
*
* @param location The Bukkit location
* @return a WorldEdit vector
*/
2018-12-23 16:19:33 +00:00
public static Vector3 asVector(org.bukkit.Location location) {
checkNotNull(location);
return Vector3.at(location.getX(), location.getY(), location.getZ());
}
2019-06-06 22:39:51 +00:00
/**
* Create a WorldEdit BlockVector from a Bukkit location.
2019-06-06 22:39:51 +00:00
*
* @param location The Bukkit location
* @return a WorldEdit vector
*/
2018-12-23 16:19:33 +00:00
public static BlockVector3 asBlockVector(org.bukkit.Location location) {
2019-06-06 22:39:51 +00:00
checkNotNull(location);
return BlockVector3.at(location.getX(), location.getY(), location.getZ());
2018-12-23 16:19:33 +00:00
}
2019-06-06 22:39:51 +00:00
/**
* Create a WorldEdit entity from a Bukkit entity.
*
* @param entity the Bukkit entity
* @return a WorldEdit entity
*/
public static Entity adapt(org.bukkit.entity.Entity entity) {
//FAWE start - logic moved to IBukkitAdapter
2019-10-23 04:23:52 +00:00
return getAdapter().adapt(entity);
//FAWE end
}
2019-06-06 22:39:51 +00:00
/**
* Create a Bukkit Material form a WorldEdit ItemType.
2019-06-06 22:39:51 +00:00
*
* @param itemType The WorldEdit ItemType
* @return The Bukkit Material
*/
public static Material adapt(ItemType itemType) {
//FAWE start - logic moved to IBukkitAdapter
2019-10-23 04:23:52 +00:00
return getAdapter().adapt(itemType);
//FAWE end
}
2019-06-06 22:39:51 +00:00
/**
* Create a Bukkit Material form a WorldEdit BlockType.
2019-06-06 22:39:51 +00:00
*
* @param blockType The WorldEdit BlockType
* @return The Bukkit Material
*/
2019-09-21 01:52:35 +00:00
public static Material adapt(BlockType blockType) {
//FAWE start - logic moved to IBukkitAdapter
2019-10-23 04:23:52 +00:00
return getAdapter().adapt(blockType);
//FAWE end
}
2019-06-06 22:39:51 +00:00
/**
* Create a WorldEdit GameMode from a Bukkit one.
*
* @param gameMode Bukkit GameMode
* @return WorldEdit GameMode
*/
2018-07-22 05:36:50 +00:00
public static GameMode adapt(org.bukkit.GameMode gameMode) {
//FAWE start - logic moved to IBukkitAdapter
2019-10-23 04:23:52 +00:00
return getAdapter().adapt(gameMode);
//FAWE end
2018-07-22 05:36:50 +00:00
}
2019-02-16 07:27:00 +00:00
/**
* Create a WorldEdit BiomeType from a Bukkit one.
*
* @param biome Bukkit Biome
* @return WorldEdit BiomeType
*/
public static BiomeType adapt(Biome biome) {
//FAWE start - logic moved to IBukkitAdapter
2019-10-23 04:23:52 +00:00
return getAdapter().adapt(biome);
//FAWE end
2019-02-16 07:27:00 +00:00
}
public static Biome adapt(BiomeType biomeType) {
//FAWE start - logic moved to IBukkitAdapter
2019-10-23 04:23:52 +00:00
return getAdapter().adapt(biomeType);
//FAWE end
2019-02-16 07:27:00 +00:00
}
2018-08-13 12:29:48 +00:00
/**
* Create a WorldEdit EntityType from a Bukkit one.
*
* @param entityType Bukkit EntityType
* @return WorldEdit EntityType
*/
public static EntityType adapt(org.bukkit.entity.EntityType entityType) {
//FAWE start - logic moved to IBukkitAdapter
2019-10-23 04:23:52 +00:00
return getAdapter().adapt(entityType);
//FAWE end
2018-08-13 12:29:48 +00:00
}
public static org.bukkit.entity.EntityType adapt(EntityType entityType) {
//FAWE start - logic moved to IBukkitAdapter
2019-10-23 04:23:52 +00:00
return getAdapter().adapt(entityType);
//FAWE end
2018-08-13 12:29:48 +00:00
}
private static final EnumMap<Material, BlockType> materialBlockTypeCache = new EnumMap<>(Material.class);
private static final EnumMap<Material, ItemType> materialItemTypeCache = new EnumMap<>(Material.class);
2020-03-24 16:15:24 +00:00
2019-06-06 22:39:51 +00:00
/**
* Converts a Material to a BlockType.
2019-06-06 22:39:51 +00:00
*
* @param material The material
* @return The blocktype
*/
2020-03-24 16:15:24 +00:00
@Nullable
2019-09-21 01:52:35 +00:00
public static BlockType asBlockType(Material material) {
//FAWE start - logic moved to IBukkitAdapter
2019-10-23 04:23:52 +00:00
return getAdapter().asBlockType(material);
//FAWE end
2018-07-22 05:36:50 +00:00
}
2019-06-06 22:39:51 +00:00
/**
* Converts a Material to a ItemType.
2019-06-06 22:39:51 +00:00
*
* @param material The material
* @return The itemtype
*/
2020-03-24 16:15:24 +00:00
@Nullable
2018-07-22 05:36:50 +00:00
public static ItemType asItemType(Material material) {
//FAWE start - logic moved to IBukkitAdapter
2019-10-23 04:23:52 +00:00
return getAdapter().asItemType(material);
//FAWE end
2018-07-22 05:36:50 +00:00
}
2020-03-24 16:15:24 +00:00
private static final Int2ObjectMap<BlockState> blockStateCache = new Int2ObjectOpenHashMap<>();
private static final Map<String, BlockState> blockStateStringCache = new HashMap<>();
2019-06-06 22:39:51 +00:00
/**
* Create a WorldEdit BlockState from a Bukkit BlockData.
2019-06-06 22:39:51 +00:00
*
* @param blockData The Bukkit BlockData
* @return The WorldEdit BlockState
*/
public static BlockState adapt(@Nonnull BlockData blockData) {
//FAWE start - logic moved to IBukkitAdapter
2018-08-27 16:56:28 +00:00
return getAdapter().adapt(blockData);
//FAWE end
}
2020-03-24 16:15:24 +00:00
private static final Int2ObjectMap<BlockData> blockDataCache = new Int2ObjectOpenHashMap<>();
2020-03-24 16:15:24 +00:00
/**
* Create a Bukkit BlockData from a WorldEdit BlockStateHolder.
*
* @param block The WorldEdit BlockStateHolder
* @return The Bukkit BlockData
*/
public static BlockData adapt(@Nonnull BlockStateHolder block) {
//FAWE start - logic moved to IBukkitAdapter
2019-07-22 20:42:40 +00:00
return getAdapter().adapt(block);
//FAWE end
2018-08-27 16:56:28 +00:00
}
2019-06-06 22:39:51 +00:00
/**
* Create a WorldEdit BlockState from a Bukkit ItemStack.
2019-06-06 22:39:51 +00:00
*
* @param itemStack The Bukkit ItemStack
* @return The WorldEdit BlockState
*/
public static BlockState asBlockState(ItemStack itemStack) throws WorldEditException {
//FAWE start - logic moved to IBukkitAdapter
2019-10-23 04:23:52 +00:00
return getAdapter().asBlockState(itemStack);
//FAWE end
}
2019-06-06 22:39:51 +00:00
/**
* Create a WorldEdit BaseItemStack from a Bukkit ItemStack.
2019-06-06 22:39:51 +00:00
*
* @param itemStack The Bukkit ItemStack
* @return The WorldEdit BaseItemStack
*/
public static BaseItemStack adapt(ItemStack itemStack) {
//FAWE start - logic moved to IBukkitAdapter
2019-10-23 04:23:52 +00:00
return getAdapter().adapt(itemStack);
//FAWE end
}
2019-06-06 22:39:51 +00:00
/**
* Create a Bukkit ItemStack from a WorldEdit BaseItemStack.
2019-06-06 22:39:51 +00:00
*
* @param item The WorldEdit BaseItemStack
* @return The Bukkit ItemStack
*/
public static ItemStack adapt(BaseItemStack item) {
//FAWE start - logic moved to IBukkitAdapter
2019-10-23 04:23:52 +00:00
return getAdapter().adapt(item);
//FAWE end
}
2020-03-24 16:15:24 +00:00
}